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

Seting the value of a multi line text box,check box and combo box

Status
Not open for further replies.

AppDev76

Programmer
Jun 8, 2004
65
US
Hi,
I was wondering how to set a default value of a text box (multi line),check box and combo box on a form to a session variable.

I've got it working for single lines, but for some reason its not working for mulit line text boxes, check boxes and combo boxes.

Thanks
 
Code:
<% if request.form("submit") = "submit" then %>

<%
Session("ElementOne") = Request.form("ElementOne")
Session("mytextarea") = Request.form("mytextarea")
Session("myradiobutton") = Request.form("myradiobutton")
%>


<% end if %>


<HTML>
blah blah blah
<form>
<input type="text" name="ElementOne" value="my default value">
<Textarea name="mytextarea"></textarea>
<input type="checkbox" name="myradiobutton" value="1">
<input type="checkbox" name="myradiobutton" value="2">
<input type="submit" name="submit" value="submit">
</form>
blah blah blah
</HTML>

 
Thanks for your reply.
I'v got the test area working but my combo boxes won't work:

<select name="Gender" class="Formborder" value=<%=Session("gender")%>>
<option value="NULL"></option>
<option value="0">Male</option>
<option value="1">Female</option>
</select>
 
You do not set a value in the select tag.
 
so where can I set a default value for a combo box?
 
Set the option you want to "selected" like so:
Code:
        <select name="Gender" class="Formborder">
          <option value="NULL" [highlight]selected[/highlight]></option>
          <option value="0">Male</option>
          <option value="1">Female</option>
        </select>

This will require a few if statements to check for each option. If you are aiming for XHTML compliance then it would look like:
Code:
        <select name="Gender" class="Formborder">
          <option value="NULL" [highlight]selected="selected"[/highlight]></option>
          <option value="0">Male</option>
          <option value="1">Female</option>
        </select>

-T

01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
The never-completed website:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top