Reputation: 1036
I have 2 drop down lists, ddl1 and ddl2. I use javaScript so that if ddl1 changes to a specific value, ddl2 becomes disabled and defaults to an item in it's list. This works fine.
However, when I click "Add", which posts back to the server, the value from ddl2 isn't set to what the javaScript set it.
How do I make that value available server side? I am assuming I need to make an AJAX call.
Upvotes: 1
Views: 129
Reputation: 2246
Disabled form fields do not get posted when you submit the form. They are treated as though they don't exist. You could try setting a hidden field via your JavaScript and then looking for that field on the server side. In fact, you could name the hidden field the same as the 2nd dropdown, but please don't forget to remove the hidden field if you once again enable the dropdown.
Also, as mentioned in the comments, you could make the dropdown "readonly" instead of "disabled" and it should avoid this problem.
I hope that helps!
Upvotes: 3