Click to See Complete Forum and Search --> : Help OnChange Event


Webgirl32
10-22-2004, 01:36 PM
Okay i am having some trouble with an on Change Event. I have a drop down that selects a subdivsion. Once that subdivsion is seleted I want it to insert that Subdivision into a test box and in a second textbox insert the value assocaited with that sub division. Can Anyone help??? The OnChange works but once you select a different subdivision it changes both of them to the Subdivision ID instead of one being the Subdivision and the other the Subdivision ID

<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="../../Connections/connHopkins.asp" -->
<%
Dim rsNew
Dim rsNew_numRows

Set rsNew = Server.CreateObject("ADODB.Recordset")
rsNew.ActiveConnection = MM_connHopkins_STRING
rsNew.Source = "SELECT * FROM hopkins.tblSubdivision"
rsNew.CursorType = 0
rsNew.CursorLocation = 2
rsNew.LockType = 1
rsNew.Open()

rsNew_numRows = 0
%>

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form>
<select name="sections" onChange="document.forms[0].hiddenfield.value = this.value; document.forms[0].hiddenfield2.value = this.value;">
<%
While (NOT rsNew.EOF)
%>
<option value="<%=(rsNew.Fields.Item("SubdivisionID").Value)%>"><%=(rsNew.Fields.Item("SubdivisionID").Value)%></option>
<%
rsNew.MoveNext()
Wend
If (rsNew.CursorType > 0) Then
rsNew.MoveFirst
Else
rsNew.Requery
End If
%>
</select>
<input type="text" name="hiddenfield" size="20" value="<%=(rsNew.Fields.Item("strSubdivision").Value)%>">
<input type="text" name="hiddenfield2" size="20" value="<%=(rsNew.Fields.Item("SubdivisionID").Value)%>">
</form>

</body>
</html>
<%
rsNew.Close()
Set rsNew = Nothing
%>

schizo
10-22-2004, 02:02 PM
Try this...


<select name="sections" onChange="document.forms[0].hiddenfield.value = this.options[this.selectedIndex].text; document.forms[0].hiddenfield2.value = this.value;">


If I understand correctly, you are trying to store both the selected text and the selected value? Your example showed you storing the selected value twice.

Webgirl32
10-22-2004, 02:31 PM
Thank you SO very much!!!

schizo
10-22-2004, 02:33 PM
No problem, glad you got it worked out :)