INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Pass value to checkbox

How to pass a value from Drop-down to Textbox... by GUJUm0deL
Posted: 11 Jun 02

Hiya, folks...this script will pass a value from the drop-down select box to the textbox...
  This can be done two ways:  one is via the onClick even handler in the <form> tag and the other is in the <input button> tag...
  The diff. is, the first way (<form> way) will pass the value as soon as the value is selected, while the later version (<input button> way) will only pass it after the user hits the button...

  This is the <form> way:

<html>
<head>
<title>Drop DOwn and Textbox</title>

<script language="javascript">
function displ()
{
  if(document.myFORM.valu.options[0].value == true) {
    return false
  }
  else {
document.myFORM.textfield.value=document.myFORM.valu.options[document.myFORM.valu.selectedIndex].value;
  }
  return true;
}
//-->
</script>

</head>

<body bgcolor="#FFFFFF" text="#000000">
<table border="0" cellspacing="0" cellpadding="0" width="75%">
  <tr>
<td width="100%"><form name="myFORM" onClick="return displ();">
        <p>
          <select name="valu" size="1">
            <option value>Choose One</option>
            <option value="MT001">MT0001 | Copper Cable Shield 1</option>
            <option value="MT002">MT0002 | Copper Cable Shield 2</option>
            <option value="MT003">MT0003 | Copper Cable Shield 3</option>
          </select>
          <input type="text" name="textfield">
        </p>
</form>
</td>
</tr>
</table>
</body>
</html>


Back to Javascript FAQ Index
Back to Javascript Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close