Jump to content

if onselect is 'other' then un-disable next field.


jasonc

Recommended Posts

How can I get the form to un-disable the second field if the first selection made is 'other'

 

but if another selection is made then the field stays disbled.

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form name="form1" method="post" action="">
  <select name="select">
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
    <option value="other">other</option>
  </select>
  <br>
  <br>
  <input type="text" name="textfield">
</form>
</body>
</html>

UPDATED:  but still not changing the next field to un-disabled.

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
<!--
function check_select(form, selection, other) {
var theform = document.getElementById(form);
var theselection = theform.selection.value;
if ((theselection == "other")) {
								theselection.disabled = false;
								} else {
										theselection.disabled = true;
										}
}
-->
</script>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
  <select name="selection" onChange="check_select('form1', 'selection', 'other')">
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
    <option value="other">other</option>
  </select>
  <br>
  <br>
  <input id="other" type="text" name="other" disabled>
</form>
</body>
</html>

onChange="check_select(); return false"

 

function check_select() {

id = document.form1.elements["selection"].selectedIndex;

vel = document.form1.options[id].value

if (vel == other) {

document.getElementByID['textbox'].disabled = false;

} else {

document.getElementByID['textbox'].disabled = true;

}

}

 

something like that could work..  though it's not tested.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.