Solved

Checkbox always return empty string!

Posted on 2011-09-04
5
251 Views
Last Modified: 2012-05-12
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?
0
Comment
Question by:Sindibad_123
5 Comments
 
LVL 13

Expert Comment

by:Cedric Obinna A.
ID: 36480305
Try changing the name to something else (say chkbox) to differentiate it from the value and try again.
0
 

Author Comment

by:Sindibad_123
ID: 36480342
that makes no difference.
0
 
LVL 13

Expert Comment

by:samic400
ID: 36480374
How is the <form> tag set up? Is the method=post?
0
 
LVL 28

Expert Comment

by:sammySeltzer
ID: 36480400
What is the data type on your db?
0
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 500 total points
ID: 36482289
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

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now