Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Checkbox always return empty string!

Posted on 2011-09-04
5
Medium Priority
?
259 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 29

Expert Comment

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

Accepted Solution

by:
Scott Fell,  EE MVE earned 2000 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

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

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

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
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/…
Integration Management Part 2
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month20 days, 20 hours left to enroll

810 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