bcode Posted December 9, 2009 Share Posted December 9, 2009 My problem is I can get the country to preselect based on what is outputted from the server but can't get the state or city to work? I have tried default value but it doesnt read the VAR selectedS for the state also I tried preselecting the state with the Var like I did with the country and not working either. Also I hope I didnt post in the wrong forum I didnt think this was an ajax problem. Sorry if this is confusing I am confused myself I am not that good with Javascript <script type="text/javascript"> var selected = "<?php echo $selectedcountry; ?>"; var selectedS = "<?php echo $selectedstate; ?>"; var selectedC = "<?php echo $selectedcity; ?>"; $(document).ready(function(){ var countryoptions = { "United States" : { "key" : 'United States', "defaultvalue" : "selectedS", "values" : { "Alabama": 'AL', } }, "Mexico" : { "key" : 'Mexico', "defaultvalue" : "selectedS", "values" : { "Baja California": 'Baja CA', } } }; var options = { preselectFirst: selected, preselectFirst: selectedS, emptyOption: true }; $('#country').doubleSelect('state', countryoptions, options); var selectoptions = { "Alabama": { "key" : 'AL', "defaultvalue" : selectedC, "values" : { "Birmingham": 'Birmingham', } }, "Baja California": { "key" : 'Baja CA', "values" : { "Tijuana": 'Tijauna', "Tecate": 'Tecate', } } }; $('#state').doubleSelect('city', selectoptions, options); }) </script> Quote Link to comment Share on other sites More sharing options...
JustLikeIcarus Posted December 10, 2009 Share Posted December 10, 2009 Looks like one problem is that your "options" has preselectFirst twice, I believe the second one should be preselectSecond. Quote Link to comment Share on other sites More sharing options...
bcode Posted December 10, 2009 Author Share Posted December 10, 2009 Yeah sorry I was copying those around to show what I have tried but it doesnt work with it being preselectSecond either. Quote Link to comment Share on other sites More sharing options...
JustLikeIcarus Posted December 10, 2009 Share Posted December 10, 2009 I removed "emptyOption: true" from your code and it worked fine for me. Quote Link to comment Share on other sites More sharing options...
bcode Posted December 10, 2009 Author Share Posted December 10, 2009 Thanks that worked for me too. Man I was staring at that for awhile needed some outside advice awesome Thanks again. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.