aragon127
09-19-2002, 09:34 PM
Here's some javascrip from my site. What happens is a user clicks the dropdown box and selects a country, which populates the state list. I only use 1 country, so I'm trying to modify it so the country(whose number is 223) is automatically populated and the state box is automatically filled. I can't quite get it right. This uses a combination of javascript & php. Thanks.
<script language="javascript"><!--
function resetStateText(theForm) {
theForm.state.value = '';
if (theForm.zone_id.options.length > 1) {
theForm.state.value = "<?php echo JS_STATE_SELECT; ?>";
}
}
function resetZoneSelected(theForm) {
if (theForm.zone_id.options.length > 1) {
theForm.state.value = "<?php echo JS_STATE_SELECT; ?>";
}
}
function update_zone(theForm) {
var NumState = theForm.zone_id.options.length;
var SelectedCountry = '';
while(NumState > 0) {
NumState--;
theForm.zone_id.options[NumState] = null;
}
SelectedCountry = theForm.country.options[theForm.country.selectedIndex].value;
<?php tep_js_zone_list('SelectedCountry', 'theForm'); ?>
resetStateText(theForm);
}
//--></script>
<script language="javascript"><!--
function resetStateText(theForm) {
theForm.state.value = '';
if (theForm.zone_id.options.length > 1) {
theForm.state.value = "<?php echo JS_STATE_SELECT; ?>";
}
}
function resetZoneSelected(theForm) {
if (theForm.zone_id.options.length > 1) {
theForm.state.value = "<?php echo JS_STATE_SELECT; ?>";
}
}
function update_zone(theForm) {
var NumState = theForm.zone_id.options.length;
var SelectedCountry = '';
while(NumState > 0) {
NumState--;
theForm.zone_id.options[NumState] = null;
}
SelectedCountry = theForm.country.options[theForm.country.selectedIndex].value;
<?php tep_js_zone_list('SelectedCountry', 'theForm'); ?>
resetStateText(theForm);
}
//--></script>