473,513 Members | 2,618 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Checkbox Value (classic Asp) How To Get The Value?

11 New Member
Hi Guys,

I am just new with classic asp. I am doing a simple website where in the user can select different categories by checking the checkboxes. But before I will do the the program that will save to the database I made first a sort of simple classic asp program. But I am stuck with my code, and I just don't know if what's the problem if why it doesn't display anything on X: and Y: when I click the submit button.

I hope you can help me with this problem of mine. Below is my test source code, Classic ASP.

Thanks in advance.



<%
Dim CheckX
Dim CheckY

Sub DisplayCheckBox
If Request.Form("x") <> "" Then
CheckX = "Checked"
Else
CheckX ="Not"
End if
If Request.Form("y") <> "" Then
CheckY ="Checked"
Else
CheckY ="Not"
End If
End Sub
%>
<HTML>
<HEAD>
</HEAD>
<BODY>
<form name="frmMain" action="checkbox1.asp" method=post>
<tr><input type="checkbox" name="x" checked="checked"></tr>
<tr><input type="checkbox" name="y" checked="checked"></tr>
<input type="button" value="submit" OnClick=<% DisplayCheckBox %>>
<tr></br></br>
<td>x: <%= CheckX %></td>
</tr>
<tr>
<td>y: <%= CheckY %></td>
</tr>
</form>

<P>&nbsp;</P>

</BODY>
</HTML>
Apr 5 '07 #1
2 63455
jhardman
3,406 Recognized Expert Specialist
The answer is a little simpler than you think. The response sent by the form for a checked checkbox should be "on", and I was thinking they sent something for unchecked, but I guess not. In your "displayCheckBox" subroutine, you make the assumption that if it is not checked you will get nothing, which is valid, but when you are filling out the table, you actually never call the subroutine (in other words you left instructions on how to check the values of the checkbox, but you never actually told the script to check). Anyway, I would take the checking out of a subroutine, it just slowed you down.

Anyway, try the below code: (i saved it all as "samePage.asp" and tested it at www.worksonline.org/temp/samePage.asp)
Expand|Select|Wrap|Line Numbers
  1. <%
  2. if request("x") = "" then %>
  3.    There was no info sent for "x".  <br>
  4. <%
  5. else
  6.    response.write "x = " & request("x") & "<br>"& vbNewLine
  7. end if
  8.  
  9. if request("y") = "" then %>
  10.    There was no info sent for "y".  <br>
  11. <%
  12. else
  13.    response.write "y = " & request("y") & "<br>"& vbNewLine
  14. end if %>
  15.  
  16. <form method="post" action="samePage.asp">
  17. <fieldset><label for="x">x: </label><input type="checkbox" name="x"
  18. <% if request("x") = "on" then response.write " checked "%>
  19. ></fieldset>
  20. <fieldset><label for="y">y: </label><input type="checkbox" name="y"
  21. <% if request("y") = "on" then response.write " checked "%>
  22. ></fieldset><input type="submit" name="submit" value="submit">
  23. </form>
Let me know if this helps.

Jared
Apr 5 '07 #2
hifiger2004
11 New Member
You're definitely correct. Thank you Jhard, you know I feel like it's my first day in school :) Whenever I have another question I hope you'll still answer it. Thanks again :)


The answer is a little simpler than you think. The response sent by the form for a checked checkbox should be "on", and I was thinking they sent something for unchecked, but I guess not. In your "displayCheckBox" subroutine, you make the assumption that if it is not checked you will get nothing, which is valid, but when you are filling out the table, you actually never call the subroutine (in other words you left instructions on how to check the values of the checkbox, but you never actually told the script to check). Anyway, I would take the checking out of a subroutine, it just slowed you down.

Anyway, try the below code: (i saved it all as "samePage.asp" and tested it at www.worksonline.org/temp/samePage.asp)
Expand|Select|Wrap|Line Numbers
  1. <%
  2. if request("x") = "" then %>
  3.    There was no info sent for "x".  <br>
  4. <%
  5. else
  6.    response.write "x = " & request("x") & "<br>"& vbNewLine
  7. end if
  8.  
  9. if request("y") = "" then %>
  10.    There was no info sent for "y".  <br>
  11. <%
  12. else
  13.    response.write "y = " & request("y") & "<br>"& vbNewLine
  14. end if %>
  15.  
  16. <form method="post" action="samePage.asp">
  17. <fieldset><label for="x">x: </label><input type="checkbox" name="x"
  18. <% if request("x") = "on" then response.write " checked "%>
  19. ></fieldset>
  20. <fieldset><label for="y">y: </label><input type="checkbox" name="y"
  21. <% if request("y") = "on" then response.write " checked "%>
  22. ></fieldset><input type="submit" name="submit" value="submit">
  23. </form>
Let me know if this helps.

Jared
Apr 5 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

19
9289
by: Adam Short | last post by:
I am trying to write a routine that will connect a .NET server with a classic ASP server. I know the following code doesn't work! The data is being returned as a dataset, however ASP does not...
2
2552
by: Shawn Berg | last post by:
Some of my pages in the app I am developing inherit from a BasePage class I have created. I have done plenty of these in the past and they work fine. Now, however, I have an additional requirement....
4
404
by: Chris Newby | last post by:
My project currently requires that I integrate an ASP.NET application with an ASP application. One of the issues I'm having is that I have some very long strings being created in an ASP.NET...
2
6986
by: Peter2 | last post by:
Hi, I have a problem posting non-ASCII characters in FORM fields between classic ASP and ASP.NET. I use a fully patched Windows 2000 Advanced Server with .net 2.0 and visual Studio 2005 installed,...
2
3494
by: needin4mation | last post by:
I can't find out if Microsoft supports "Classic" asp or if they only support asp.net? I'm not really sure what support means in either context, really, except that they tell customers not to use...
0
1720
by: deathtospam | last post by:
A few weeks ago, I created a Classic ASP page that connects to a machine with SQL Server installed on it, prompts the user to select a database on that server, then lists all of user-created stored...
9
5540
by: hifiger2004 | last post by:
Hi Guys, I have encountered this probleme when I am having a Classic ASP code that was put inside a string variable including the directives (<% %>) Page Error: Microsoft VBScript...
5
4464
by: Mike P | last post by:
I have very little experience of Classic ASP, but I need to take some data from a table, write it to the screen in a tabular format, show a check box at the end of every row, and write some code to...
1
6226
by: Aslam Shah | last post by:
I want to get the value of the checkbox in teh calssic asp. my checkbox are of this format: <input name="checkbox2" type="checkbox" id="checkbox2" value="Actin (smooth muscle) (SMA)" /> and...
1
7098
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7521
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5682
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5084
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3221
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1591
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
455
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.