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> Link to comment https://forums.phpfreaks.com/topic/184542-doubleselect-preselect/ 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. Link to comment https://forums.phpfreaks.com/topic/184542-doubleselect-preselect/#findComment-974755 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. Link to comment https://forums.phpfreaks.com/topic/184542-doubleselect-preselect/#findComment-974784 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. Link to comment https://forums.phpfreaks.com/topic/184542-doubleselect-preselect/#findComment-974807 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. Link to comment https://forums.phpfreaks.com/topic/184542-doubleselect-preselect/#findComment-974861 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.