falcondriver
Apr 28th 2006, 11:23 am
hi,
i never did javascript before (im the php/sql guy...), so im not sure whats wrong here, maybe just a syntax error. its about 2 option-fields (startcountry, endcountry), if someone changes "startcountry" then i want the same value selected as "endcountry". the user can still change "endcountry" without affecting any other fields, so no action required here.
thats what i have so far, i have no idea whats wrong:
<html><body>
<form name="rideboard" action="">
<select name="startcountry" id="startcountry" onchange="update(this.form.startcountry.value)">
<option value="1">sunny country</option>
<option value="2">backward country</option>
<option value="3">nerverheardabout country</option>
</select>
<select name="endcountry">
<option value="1">sunny country</option>
<option value="2">backward country</option>
<option value="3">nerverheardabout country</option>
</select>
</form>
<script type="text/javascript">
function update(newvalue) {
alert(newvalue);
document.rideboard.endcountry.value = newvalue;
}
}
</script>
</body></html>
this alert() is just for testing, dosnt has to be there...
i never did javascript before (im the php/sql guy...), so im not sure whats wrong here, maybe just a syntax error. its about 2 option-fields (startcountry, endcountry), if someone changes "startcountry" then i want the same value selected as "endcountry". the user can still change "endcountry" without affecting any other fields, so no action required here.
thats what i have so far, i have no idea whats wrong:
<html><body>
<form name="rideboard" action="">
<select name="startcountry" id="startcountry" onchange="update(this.form.startcountry.value)">
<option value="1">sunny country</option>
<option value="2">backward country</option>
<option value="3">nerverheardabout country</option>
</select>
<select name="endcountry">
<option value="1">sunny country</option>
<option value="2">backward country</option>
<option value="3">nerverheardabout country</option>
</select>
</form>
<script type="text/javascript">
function update(newvalue) {
alert(newvalue);
document.rideboard.endcountry.value = newvalue;
}
}
</script>
</body></html>
this alert() is just for testing, dosnt has to be there...