"remove all options from a drop down and populate it with new items
from the json"

"if possible, it will be good if i can have a default "null" option
eg
"Please select an option" that does not do anything if the user
selects it or shows at the start and disappears once user selects it?"
???

If you want the default included in the list you dynamically populate
you can do this:

$('#idOfYourDropdown').empty().append('<option value="">Please select
a value...</option>'+$.map(data,function(o,i){
return '<option value="'+o.Value+'">'+o.Item+'</option>';
}).join(''));

If you want to populate a second list, you'll need more scripting :)

I find it often helps to make a flowchart of how the application
should work, even if just a numbered list.  jQuery makes it pretty
easy to manipulate the DOM however you like. I suggest you read
through the docs and play with code, as all the necessary DOM
manipulation methods are there.

HTH :-)

On Mar 25, 5:40 pm, iceangel89 <iceange...@gmail.com> wrote:
> thanks all. but what about the default "Please select a value" option?
> how can i have it such that the user either
> - cannot select that option - shown only on 1st run
> - can select the option but will cause the 2nd dropdown to empty -
> dunno if this is good idea
>
> or any other suggestions ?
>
> btw, as for plugins theres also the jquery Cascade. but the thing is
> how can i also populate the 1st drop down dynamically? the plugin only
> handles for 2nd and subsequent dropdowns

Reply via email to