Jump to content

DoubleSelect Preselect


bcode

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.