I am trying to hide and show fields based of the selection in a dropdown field. I got it do hide but when I select another value it doesn't display again.
<script type="text/javacript">
function checkEm(){
if (document.getElementById('JobTypeDDL').selected = "2"){
document.getElementById('DateTbx').style.visibility = "hidden";
document.getElementById('DateTbx').style.display = "none";
} else {
document.getElementById('DateTbx').style.visibility = "visible";
document.getElementById('DateTbx').style.display = "block";
}
}
</script>
<div class="InputField">
<select name="JobTypeDDL" id="JobTypeDDL" onChange="checkEm()">
<option value="0" <?php if ($_POST['JobTypeDDL'] == "0") {echo "selected='selected'";} ?> >Select Job Type</option>
<option value="1" <?php if ($_POST['JobTypeDDL'] == "1") {echo "selected='selected'";} ?> >New Mobility</option>
<option value="2" <?php if ($_POST['JobTypeDDL'] == "2") {echo "selected='selected'";} ?> >Service/Repair/Install</option>
</select>
</div>
<input name="DateTbx" id="DateTbx" type="text" <?php if (!$_POST['DateTbx'] == "") {echo "value='". $_POST['DateTbx']."'";} ?> />
问问题
437 次