I've got a PHP form which using Javascript changes a form field called 'numid' when the user changes a selection dropdown called 'number':
<script type="text/javascript">
function check(number) {
if (number=="1") {
document.getElementById('numid').value="id1";
}
else if (number=="2") {
document.getElementById('numid').value="id2";
}
else if (number=="3") {
document.getElementById('numid').value="id3";
}
else if (number=="4") {
document.getElementById('numid').value="id4";
}
else {
document.getElementById('numid').value="id0";
}
}
</script>
I then simply add the following onchange event to the select dropdown:
<select id="number" name="number" onchange="check(this.value)">
and then an 'onload' function to the body tag so that if the form is passed a 'number' field from the previous page it updates the 'numid' field with the correct value too:
<body onload="check(document.getElementById('number').value);">
The thing is, now I want to keep the same functions on this page but if there is a 'numid' value added to the URL like, www.mywebsite.org.uk/?numid=id10 then this takes precedence over the other values from the selection dropdown. Therefore, the when the 'numid' is 'id10' (taken from the URL) the previous javascript check is ignored and regardless of the selection made in 'number' the value is always 'id10'.
Really appreciate your help on this. Not sure if PHP is the way to go either on this.