Checkbox always return empty string!

Sindibad_123
Sindibad_123 used Ask the Experts™
on
Hi, I have the following checkbox
<input type="checkbox" value="chkterm" name="chkterm" id="chkterm"  style="BACKGROUND:#f4f4f4" onClick="EnableSubmit();" >

and I read it like the following:
Request.form("chkterm")
But it always returns an empty string even if the checkbox is checked!

Any suggestion?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Cedric Obinna A.Full Stack Developer
Top Expert 2008

Commented:
Try changing the name to something else (say chkbox) to differentiate it from the value and try again.

Author

Commented:
that makes no difference.
Bob ButcheriSeries Engineer

Commented:
How is the <form> tag set up? Is the method=post?
Top Expert 2011

Commented:
What is the data type on your db?
Developer & EE Moderator
Fellow 2018
Most Valuable Expert 2013
Commented:
Let's say you always wanted it to be checked, then it would look something like this
<input name="chkterm" type="checkbox" id="chkterm"  style="BACKGROUND:#f4f4f4" onClick="EnableSubmit();" value="chkterm" checked="checked" >

Open in new window


So to dynamically make it work you can do a couple options like....


 Option 1
<%
dim strChkterm
if Request.form("chkterm")=<>"" then
       strChkterm=Request.form("chkterm")
end if
%>


<input type="checkbox" value="chkterm" name="chkterm" id="chkterm" <%If strChkterm = "chkterm" Then Response.Write("checked=""checked""") else Response.Write("") end if%>  style="BACKGROUND:#f4f4f4" onClick="EnableSubmit();" >

Open in new window


Option 2
<input type="checkbox" value="chkterm" name="chkterm" id="chkterm" <%If Request.form("chkterm") = "chkterm" Then Response.Write("checked=""checked""") else Response.Write("") end if%>  style="BACKGROUND:#f4f4f4" onClick="EnableSubmit();" >

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial