Reputation: 37
How can I set dropdown value from client side, I'm using countries.js file to load countries and state, Since It is loaded from client side on grid row selection (for updation) I'm unable to load country and state from server side.This is the link https://bdhacker.wordpress.com/2009/11/21/adding-dropdown-country-state-list-dynamically-into-your-html-form-by-javascript/
dropdownlist.SelectedIndex = dropdownlist.Items.IndexOf(dropdownlist.Items.FindByValue(value));
The dropdown is populated from client side,
Upvotes: 1
Views: 84
Reputation: 355
I'm not sure if I understand your question. According to your first sentence, these lines might help you in this case.
To add an option to your select;
$('#country2').append("<option value='new'>new</option>");
and select an option.
$("#country2 option[value='france']").prop('selected','selected');
Upvotes: 1