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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dropdown Menu - populate textbox with different value

Status
Not open for further replies.

Jay319

Technical User
Feb 21, 2003
16
US
Hi,

I have a dropdown menu which when an account is selected I would like to have a textbox automatically populate with the account number.

Here is what I have started ...

<script language="javascript">
function MoveacctNumber()
{
var myVar = document.form1.acctNumber.value;
document.form1.txtID.value = myVar;
}
</script>
</head>

<body>
<form name="form1">
<select name="acctNumber" id="select" OnChange="MoveacctNumber()">
<%
While (NOT rstest.EOF)
%>
<option value="<%=(rstest.Fields.Item("acctName").Value)%>" <%If (Not isNull((rstest.Fields.Item("acctName").Value))) Then If (CStr(rstest.Fields.Item("acctName").Value) = CStr((rstest.Fields.Item("acctName").Value))) Then Response.Write("SELECTED") : Response.Write("")%> ><%=(rstest.Fields.Item("acctName").Value)%></option>
<%
rstest.MoveNext()
Wend
If (rstest.CursorType > 0) Then
rstest.MoveFirst
Else
rstest.Requery
End If
%>
</select>
<br>
<input type="text" name="txtID">
</form>

My problem is that I keep populating the textbox with the accountName instead of the corresponding acctNumber.

thanks for any help,

Jay
 
You're populating the value of the option with the account name rather than the account number.

<option value="<%=(rstest.Fields.Item("acctName").Value)%>

should be

<option value="<%=(rstest.Fields.Item("acctNumber").Value)%>




Mark

"You guys pair up in groups of three, then line up in a circle."
- Bill Peterson, a Florida State football coach
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top