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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.