PDA

View Full Version : passing option select value to textbox


skalag
03-03-2003, 07:19 PM
i have used the code below to pop select option, i want to pass the selected value to the text box Tdimensions, if possible without posting a form....i want to put the value in the text box and submit that value by form to insert into db.

IF NOT rs.EOF THEN
rs.MoveFirst
%>
<select name="Sdimensions">
<option disabled>Dimensions</option>
<%
Do While Not rs.EOF
Response.Write "<option value="""
Response.Write rs.Fields("Fwidth")
Response.Write """"
Response.Write ">"
Response.Write Trim(rs.Fields("Fwidth"))
Response.Write " x "
Response.Write Trim(rs.Fields("Fheight"))
Response.Write " x "
Response.Write Trim(rs.Fields("Flength"))
Response.Write "</option>" & vbCrLf

' Move to next record
rs.MoveNext
Loop
%>
</select>
<%
END IF
%>


<INPUT type="text" name="Tdimensions" size="12">

vickers_bits
03-04-2003, 06:01 AM
why do you want to put it in a textbox?
if you request the value of the select box you'll get what you need

however you ould use client-side javascript:

<select id="Sdimenstions" onchange="this.form.Tdimensions.value=this.value;">

but the value of the textbox can be changed by the user

<input type="text" id="Tdimensions" value="" size="12" onfocus="this.blur();" />

glenngv
03-04-2003, 07:49 AM
this.value in <select> will work in IE but may not work in some browsers. This is the correct way of getting value in a <select>:

<select id="Sdimenstions" onchange="this.form.Tdimensions.value=this.options[this.selectedIndex].value;">

skalag
03-04-2003, 01:14 PM
thanks guys.