JAVASCRIPT to remember selection

I have a form where you input the country and then the next dropdown automatically selects states and then when you select the state and the next dropdown on the form automatically selects cities from that state. All this works good. BUUUUUT, when the form is submitted, if there is an error, for example, leaving a required field empty, it returns you to the form with the values already filled in. How can I get JAVASCRIPT to select the remember the selection?


function fillCountry()
	addOption(, "Mexico", "Mexico", "");
	addOption(, "United States", "United States", "");

function selectState()
	addOption(document.enterUser.state, "", "-- Select --", "");

	if( == 'Mexico')
		addOption(document.enterUser.state,"Nuevo Leon", "Nuevo Leon");
		addOption(document.enterUser.state,"Tamaulipas", "Tamaulipas");
	if( == 'United States')
		addOption(document.enterUser.state,"Texas", "Texas");

function selectCity()
	// ON selection of category this function will work

	addOption(, "", "-- Select --", "");

	if(document.enterUser.state.value == 'Nuevo Leon')
		addOption(,"Monterrey", "Monterrey");
		addOption(,"Sabinas Hidalgo", "Sabinas Hidalgo");
	if(document.enterUser.state.value == 'Tamaulipas')
		addOption(,"Nuevo Laredo", "Nuevo Laredo");
	if(document.enterUser.state.value == 'Texas')
		addOption(,"Corpus Christi", "Corpus Christi");
		addOption(,"Cotulla", "Cotulla");
		addOption(,"Eagle Pass", "Eagle Pass");
		addOption(,"Edinburg", "Edinburg");
		addOption(,"El Cenizo", "El Cenizo");
		addOption(,"Laredo", "Laredo");
		addOption(,"McAllen", "McAllen");
		addOption(,"San Antonio", "San Antonio");
		addOption(,"Sullivan City", "Sullivan City");
		addOption(,"Rio Bravo", "Rio Bravo");
		addOption(,"Zapata", "Zapata");


function removeAllOptions(selectbox)
	var i;

function addOption(selectbox, value, text )
	var optn = document.createElement("OPTION");
	optn.text = text;
	optn.value = value;


<span <?php if($repasswordMessage != ''){echo 'class="errorField"';} ?>>Re-type password: <input name="repassword" type="password" value="<?php echo $repassword; ?>" /></span>
<hr />

<span <?php if($countryMessage != ''){echo 'class="errorField"';} ?>>
Country: <select name="country" onchange="selectState();">
  <option value="" >-- Select --</option>

<span <?php if($stateMessage != ''){echo 'class="errorField"';} ?>>
	<select id="state" name="state" onchange="selectCity();" >
	<option value="" selected="selected">-- Select --</option>

<span <?php if($cityMessage != ''){echo 'class="errorField"';} ?>>
	<select id="city" name="city" >
	<option value="">-- Select --</option>

<span <?php if($zipcodeMessage != ''){echo 'class="errorField"';} ?>>Zipcode: <input name="zipcode" type="text" value="<?php echo $zipcode; ?>" /></span>
<span <?php if($addressMessage != ''){echo 'class="errorField"';} ?>>Address: <input name="address" type="text" value="<?php echo $address; ?>" /></span>