I have a form with three fields. When the user changes the value of field1, the form displays either field2 or field3. This works fine for NEW records.
However, I'm running into a problem when trying to EDIT an existing record. When the form is loaded, I need to test the value of field1 and display either field2 or field3. I've tried using the form onload event, but do not know how to access the value of field1.
I'm using Javascript and div tags.
This is what I have so far.
<script type="text/javascript">
function hide(obj)
obj1 = document.getElementById(obj);
obj1.style.display = 'none';
}
function show(obj)
{
obj1 = document.getElementById(obj);
obj1.style.display = 'block';
}
<script type = "text/javascript">
function checkField1() {
var val = document.getElementById("ClassType").value;
if(val=='C') { show('divClass');} else{hide('divClass'); }
if(val=='W') { show('divWorkshop');} else{hide('divWorkshop'); }
}
</script>
/* Field1 - is a drop down list */
<select name="ClassType" id = "ClassType" size="1" onchange="show_other(this.value)">
<body onload = "checkField1()">
Quizmaster: In which English county is the Cornish language spoken?
Contestant: Devon.
__________________
All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
BTW, when posting here please help us to help you by following the posting guidelines and wrapping your code in CODE tags. This means use the octothorpe or # button on the toolbar. You can (and should) edit your previous post.
__________________
All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.