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

OnChange just won't work

Status
Not open for further replies.

Kalor

Programmer
Jan 22, 2002
13
AU
Hi all,

I want to populate a text box based on the selected value in a SELECT list (combo box). I'm at my wits end trying to get OnChange to do ANYTHING. I've found some examples on the net but if I use the code it still does zippo.

Here's my code:
------------------------------------------------------
<%
Sub FindClassDesc()
'On Error Resume Next
'frm.txtTEST = &quot;Zippedydoodah&quot;
msgbox(&quot;hello&quot;)
End Sub
%>

(lots of html)

<select size=&quot;1&quot; name=&quot;cboUSERCLASS&quot; language=&quot;VBScript&quot; OnChange=&quot;FindClassDesc()&quot;>
<%
'--VBScript to fill combo box from a database table, which works fine
%>
</SELECT>
-------------------------------------------------

advaTHANKSnce,

Steven.
 
you can't reference a sub via server side with client side events
you would actually have to have a submission or some event that would run the code seperatly via a seperate file (.asp) or a form submit.
Another thing you can't do is have a msgbox server side. Sorry to burst your bubble man, but that's server life.

take a different approach like submiting the form on change via javascript and run the server side code to populate a new select on no error. You'll need to response.write the error to the page.
Not everything you type is understanding to others! Think about that before getting upset with a wrong answer to your question.

admin@onpntwebdesigns.com
 
If I understand your dilema, You want to fill a text box with the selected option from a dropdown list. If this is what you wish to accomplish this should do it for you...


<script language=&quot;vbscript&quot;>
Sub FindClassDesc()
'fill it with value selected
document.frm.txtTest.value=document.all.cboUserClass.value 'fill it with the text selecte
document.frm.txtTest.value=document.all.cboUserClass.options(document.all.cboUserClass.selectedIndex).text
End Sub
</script>

--other stuff--
<select size=&quot;1&quot; name=&quot;cboUSERCLASS&quot; language=&quot;VBScript&quot; OnChange=&quot;FindClassDesc()&quot;>

good luck

tsmith
 
Thanks. That would do it, but what I want is to populate the text box with data looked up in a table, based on the combo box selection (eg the user selects &quot;WA&quot; and the 'State Description' box is populated with 'Western Australia' (or Washington :) ).

As onpnt picked up, I think I'm getting client side and server side a little confused. I've developed a workaround and lowered the user's expectations a bit.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top