PDA

Click to See Complete Forum and Search --> : checkbox and asp


simonmay
Jul 11th, 2000, 05:31 PM
i have a html form that has 1 textbox and 1 checkbox

if iwant to check the value (on the server side) the code would look like this (about) response.write request.form("textbox1"), but , (there's always one) what if i want to check the checkbox value.........

The returned value of a textbox is in the "value" field, but the value of a checkbox seems to be in the "checked" field

Since the "request.form" only retrieves the value field, how do i proceed for the checked field ?


thank you all

capone
Jul 11th, 2000, 07:09 PM
Are you checking in the same page as the form is on, or are you submitting the form? If you're submitting, then give a value to the checkbox, and that will be passed to the browser IF the box is checked.
so if the name of the check box is check1, and the value is "bob" then if the checkbox is checked you'll get yoururl/yourpage?check1=bob
So on the new page you just see if check1 = bob.
If this doesn't help, post your code.

simonmay
Jul 11th, 2000, 07:20 PM
thank you capone: it works

Mark Sreeves
Jul 12th, 2000, 03:48 AM
This shows how you can test if the checkbox is checked...



<%@ Language=VBScript %>
<HTML>
<HEAD>
</HEAD>
<BODY>
<%
dim i

for i = 1 to 5
Response.Write("Checkbox " & i & ": " & request("checkbox" & i) & "<BR>")
if request("checkbox" & i)= "on" then
'this will be true if the checkbox is checked
end if
next
%>
<form action="ch.asp">
<P><INPUT id=checkbox1 name=checkbox1 type=checkbox></P>
<P><INPUT id=checkbox2 name=checkbox2 type=checkbox></P>
<P><INPUT id=checkbox3 name=checkbox3 type=checkbox></P>
<P><INPUT id=checkbox4 name=checkbox4 type=checkbox></P>
<P><INPUT id=checkbox5 name=checkbox5 type=checkbox></P>
<INPUT type=submit>

</form>
</BODY>
</HTML>