Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to enter value in textbox by selecting from combobox

Status
Not open for further replies.

yog2go

Programmer
Jul 22, 2004
18
US
Hi everyone,
I have a table(tblSOP) with four fields.
SOPID, SOPName, SOPPhoneNumber, SOPCode

I already have a combobox populated from SOPName field.
Now when i click and choose value in combobox, the corresponding SOPPhoneNumber should appear in textbox(txtPhone).

How to write script for this?
Thanks in advance.
 
Thank for the reply.
I want to display not the selected value of combobox into textbox but the corresponding SOPPhoneNumber value in textbox.
 
Something like this?
Code:
<html>
<head>
<script type="text/javascript">
<!--
var phonenumbers = new Array("1-234-567-8900","1-800-CALL-NOW","1-800-PHONENO");
// Edit this
function setNumber(s, f, t)
{
  var target = f.elements[t];
  target.value = phonenumbers[s.selectedIndex];
}
// -->
</script>
</head>
<body>
<form name="f">
<select name="phones" onchange="setNumber(this, this.form, 'number');">
<option>Sequential</option>
<option>Call Now</option>
<option>Phone Number</option>
</select>
<input type="text" name="number">
</form>
</body>
</html>

--Chessbot

"See the TURTLE of enormous girth!"
-- Stephen King, The Dark Tower series
 
I would do it this way:

Code:
  <form name="f">
    <select name="s" onchange="this.form.p.value = this.options[this.selectedIndex].value;">
      <option value="555-1212">First Phone Number</option>
      <option value="555-2424">Second Phone Number</option>
      <option value="555-3636">Third Phone Number</option>
  </form>

*cLFlaVA
----------------------------
"Holy crip he's a crapple!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top