Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 30th, 2006, 01:15 AM
Authorized User
 
Join Date: May 2006
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default peoblem with checkboxes values

hi,
i have a form with many checkboxes to select multiple options for users.. all checkboxes share same name but different values...

After submitting the form .. all fileds values are send to mail..

i m facing problem with how to catch the values of those checkboxes which are selected by the user and how can send it thourgh mail..

please suggest me

here is my mail.asp page (i coded like this)

html = html & "<table>"
for i= 1 to request.form("purpose").count
html = html & "<tr><td><b>&nbsp;" & Request.Form("purpose")(i) & "</b></td></tr>"
next
html = html & "</table>"


here;
purpose---> is the name of all checkboxexs

please help me..



shri
__________________
shri
 
Old July 3rd, 2006, 09:52 AM
Friend of Wrox
 
Join Date: Nov 2005
Posts: 223
Thanks: 0
Thanked 0 Times in 0 Posts
Default

it depends on what your goal is if you want to have 1 purpose you need radioboxes and bot checkboxes.
if you have multiple purposes you need the have a unique name
Code:
<form>
  <input type="checkbox" name="purpose1" value="" />
  <input type="checkbox" name="purpose2" value="" />
  <input type="checkbox" name="purpose3" value="" />
</form>

<form>
  <input type="radiobox" name="purpose1" value="1" />
  <input type="radiobox" name="purpose2" value="2" />
  <input type="radiobox" name="purpose3" value="3" />
</form>
asuming your situation is correct then you could use a do loop
here is example using an array
Code:
dim famname(5)
dim i
i=0
famname(0)="Jan Egil"
famname(1)="Tove"
famname(2)="Hege"
famname(3)="Stale"
famname(4)="Kai Jim"
famname(5)="Borge"

do while famname(i)<>""
  Reponse.write(famname(i))
  i=i+1
loop

__________________________________________________ ________
This is my junk I'm gona eat it
 
Old July 4th, 2006, 09:19 AM
Authorized User
 
Join Date: Jun 2003
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to erobb Send a message via Yahoo to erobb
Default

>purpose---> is the name of all checkboxexs

Yes the collection technique you are using is for a checkbox array

ie you are using check box names like
  <input type="checkbox" name="purpose" value="1" />
  <input type="checkbox" name="purpose" value="2" />
  <input type="checkbox" name="purpose" value="3" />

To designate multiple checkboxes and collect them dyamically while still retaining multiple names for your checkboxes have you tried something like this?

----------Page with your form items

  <input type="checkbox" name="purpose1" value="1" />
  <input type="checkbox" name="purpose2" value="2" />
  <input type="checkbox" name="purpose3" value="3" />

----------Page Collecting the Values

for i=1 to 3
  if request.form("purpose"&i) <> "" then
    response.write "value purpose"&i&"="&request.form("purpose"&i)
  end if
next

Earl
www.jhdesigninc.com


 
Old August 19th, 2006, 02:03 AM
Registered User
 
Join Date: Aug 2006
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to albertindian2000
Default

Hey,

This is very simple. When all the checkboxes share the same name during the form submit the checkbox name will have the values of which the check boxes are checked

For eg CB(1) value is 1,CB(2) value is 5 and CB(3) value is 6 In this user selected CB(1) and cb(2) then the request(cb) will have 1,5 as value

The code for this will be like below

<input type="checkbox" name="purpose" value="1" />
<input type="checkbox" name="purpose" value="2" />
<input type="checkbox" name="purpose" value="3" />
<input type="checkbox" name="purpose" value="4" />
<input type="checkbox" name="purpose" value="5" />
<input type="checkbox" name="purpose" value="7" />


ASP Code will be

<%
strPurpose =request("purpose")
strPurposeArray=split(strPurpose,",")

For i=0 to ubound(strPurposeArray)
       response.write strPurposeArray(i) & "<br>"
Next
%>

The above code will get all the values and print in the screen.

Albert Arul prakash
http://www.bepenfriends.com






Similar Threads
Thread Thread Starter Forum Replies Last Post
How 2 store checkboxes values in MySQL babaloui Beginning PHP 0 March 13th, 2006 04:05 AM
Dynamic Checkboxes using dynamic Select Values bsheridan Classic ASP Databases 0 March 12th, 2006 10:17 AM
Using Checkboxes in datagrid ractim General .NET 2 September 21st, 2004 05:14 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.