Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Apr 25, 2012 10:15 PM by LearningASP_C_Sharp
Member
242 Points
256 Posts
Apr 25, 2012 09:52 PM|LINK
Hi
I have the following jQuery code which is supposed to select GBP from a ddl, but for some reason it not working.
Anyone spot what is wrong:
Thanks
George
//**************************************** // // SELECT GBP FROM CURRENCY LIST // //**************************************** if (!$("#ConvertFrom option:selected").length) $("#ConvertFrom option[value='GBP']").attr('selected', 'selected');
Snippit of html
<select id="ConvertFrom" name="ConvertFrom">
All-Star
27554 Points
4912 Posts
MVP
Apr 25, 2012 10:01 PM|LINK
Why don't you do this:
$("#ConvertFrom").val('GBP')
Apr 25, 2012 10:04 PM|LINK
Hi BrockAllen
Just tried that and still does not work
Apr 25, 2012 10:07 PM|LINK
Works for me -- here's the sample to confirm. Maybe you have something else that's beyond the sample that's causing problems:
<select id="foo"> <option value="USD">Dollars</option> <option value="GBP">Pounds</option> </select> <script> $(function () { $("#foo").val("GBP"); }); </script>
Apr 25, 2012 10:15 PM|LINK
Yep works now, closed visual studio and opened and now works
LearningASP_...
Member
242 Points
256 Posts
Select option in list
Apr 25, 2012 09:52 PM|LINK
Hi
I have the following jQuery code which is supposed to select GBP from a ddl, but for some reason it not working.
Anyone spot what is wrong:
Thanks
George
//**************************************** // // SELECT GBP FROM CURRENCY LIST // //**************************************** if (!$("#ConvertFrom option:selected").length) $("#ConvertFrom option[value='GBP']").attr('selected', 'selected');Snippit of html
BrockAllen
All-Star
27554 Points
4912 Posts
MVP
Re: Select option in list
Apr 25, 2012 10:01 PM|LINK
Why don't you do this:
$("#ConvertFrom").val('GBP')DevelopMentor | http://www.develop.com
thinktecture | http://www.thinktecture.com/
LearningASP_...
Member
242 Points
256 Posts
Re: Select option in list
Apr 25, 2012 10:04 PM|LINK
Hi BrockAllen
Just tried that and still does not work
George
BrockAllen
All-Star
27554 Points
4912 Posts
MVP
Re: Select option in list
Apr 25, 2012 10:07 PM|LINK
Works for me -- here's the sample to confirm. Maybe you have something else that's beyond the sample that's causing problems:
<select id="foo"> <option value="USD">Dollars</option> <option value="GBP">Pounds</option> </select> <script> $(function () { $("#foo").val("GBP"); }); </script>DevelopMentor | http://www.develop.com
thinktecture | http://www.thinktecture.com/
LearningASP_...
Member
242 Points
256 Posts
Re: Select option in list
Apr 25, 2012 10:15 PM|LINK
Hi
Yep works now, closed visual studio and opened and now works
Thanks
George