Solved

Checkbox always return empty string!

Posted on 2011-09-04
5
252 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
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…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

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