stevema4567
08-09-2006, 07:05 PM
I am new to this. Please help!
How do I display a textbox only if a certain value is selected from a dropdown list within a form?
I have the following code which is pulling values into a dropdown list from a sql database. If the selected item = Enter/Edit/Delete Beyond 60 days then I need to display a text box for the user to type in a reason.
<tr class=formlabel><td colspan=2 height=<%=spacerheight%>></td></tr>
<%
Category_name = rstemp2("Category_name")
Category_number = rstemp2("Category_number")
Category_index = rstemp2("Category_index")
%>
<tr><td align=right width=<%=widthpercent%> class=formlabel>
<%
response.write Category_name & ":</td><td align=left class=formboxholder>"
response.write "<select name=c" & rstemp2("category_number") & " size = 1>"
response.write "<option value= >Ignore</option>"
Do While rstemp2.EOF <> True
'-->AKS<-- Added CINT functions to match both sides of <>.
if CInt(rstemp2("Category_number")) <> CInt(Category_number) THEN
response.write "</select></td>"
response.write "</tr>"
Response.write "<td align=right class=formlabel>"
Response.write rstemp2("Category_Name") & ":</td><td align=left class=formboxholder>" & chr(10)
response.write "<select name=c" & rstemp2("category_number") & " size = 1>" & chr(10)
response.write "<option value= >Ignore</option>"
Category_number = rstemp2("Category_number")
End If
' Checked if this option is already select for this case
If CaseNumber <> "" Then
'-->AKS<-- Added CInt function to match both sides of =
If CInt(rstemp("C" & Category_number)) = CInt(rstemp2("item_number")) Then
response.write "<option SELECTED value=" & rstemp2("item_number") & ">" & rstemp2("item_name") & "</option>" & chr(10) & chr(13)
Else
response.write "<option value=" & rstemp2("item_number") & ">" & rstemp2("item_name") & "</option>" & chr(10) & chr(13)
End IF
End If ' End of case_number <> ""
If CaseNumber = "" Then
response.write "<option value=" & rstemp2("item_number") & ">" & rstemp2("item_name") & "</option>" & chr(10) & chr(13)
End If
rstemp2.MoveNext
Loop
response.write "</select></td></tr></table></center>"
End IF
rstemp2.close
set rstemp2=nothing
' If Not new case then close the other record set
If Case_Number <> "" Then
rstemp.close ' close the original record set
set rstemp=nothing
End IF
conntemp.close ' Close the connection
set conntemp=nothing
%>
</td></tr>
How do I display a textbox only if a certain value is selected from a dropdown list within a form?
I have the following code which is pulling values into a dropdown list from a sql database. If the selected item = Enter/Edit/Delete Beyond 60 days then I need to display a text box for the user to type in a reason.
<tr class=formlabel><td colspan=2 height=<%=spacerheight%>></td></tr>
<%
Category_name = rstemp2("Category_name")
Category_number = rstemp2("Category_number")
Category_index = rstemp2("Category_index")
%>
<tr><td align=right width=<%=widthpercent%> class=formlabel>
<%
response.write Category_name & ":</td><td align=left class=formboxholder>"
response.write "<select name=c" & rstemp2("category_number") & " size = 1>"
response.write "<option value= >Ignore</option>"
Do While rstemp2.EOF <> True
'-->AKS<-- Added CINT functions to match both sides of <>.
if CInt(rstemp2("Category_number")) <> CInt(Category_number) THEN
response.write "</select></td>"
response.write "</tr>"
Response.write "<td align=right class=formlabel>"
Response.write rstemp2("Category_Name") & ":</td><td align=left class=formboxholder>" & chr(10)
response.write "<select name=c" & rstemp2("category_number") & " size = 1>" & chr(10)
response.write "<option value= >Ignore</option>"
Category_number = rstemp2("Category_number")
End If
' Checked if this option is already select for this case
If CaseNumber <> "" Then
'-->AKS<-- Added CInt function to match both sides of =
If CInt(rstemp("C" & Category_number)) = CInt(rstemp2("item_number")) Then
response.write "<option SELECTED value=" & rstemp2("item_number") & ">" & rstemp2("item_name") & "</option>" & chr(10) & chr(13)
Else
response.write "<option value=" & rstemp2("item_number") & ">" & rstemp2("item_name") & "</option>" & chr(10) & chr(13)
End IF
End If ' End of case_number <> ""
If CaseNumber = "" Then
response.write "<option value=" & rstemp2("item_number") & ">" & rstemp2("item_name") & "</option>" & chr(10) & chr(13)
End If
rstemp2.MoveNext
Loop
response.write "</select></td></tr></table></center>"
End IF
rstemp2.close
set rstemp2=nothing
' If Not new case then close the other record set
If Case_Number <> "" Then
rstemp.close ' close the original record set
set rstemp=nothing
End IF
conntemp.close ' Close the connection
set conntemp=nothing
%>
</td></tr>