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>

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.