ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 4th, 2003, 05:20 PM
Tyssen Tyssen is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Brisbane
Posts: 129 Tyssen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 31 m 55 sec
Reputation Power: 6
Question Multiple checkbox only passing one value

I have a series of checkboxes:

Code:
<td><input type="checkbox" name="reportTo" value="Rob"></td>
<td><input type="checkbox" name="reportTo" value="John"></td>

etc...

but I only get a value passed to the database if just one is selected. If more than one is selected, no value is returned. I thought the value passed was s'posed to be a comma delimited string of all checked boxes?

Reply With Quote
  #2  
Old November 4th, 2003, 08:03 PM
russpang russpang is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Location: Florida
Posts: 3 russpang User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to russpang Send a message via Yahoo to russpang
Can you post your output?

Reply With Quote
  #3  
Old November 4th, 2003, 09:07 PM
Tyssen Tyssen is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Brisbane
Posts: 129 Tyssen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 31 m 55 sec
Reputation Power: 6
If I click on the checkbox named "John", I get John.
If I click on the checkbox named "Rob", I get Rob.
If I click on both of them, I get nothing.

Reply With Quote
  #4  
Old November 5th, 2003, 06:08 AM
russpang russpang is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Location: Florida
Posts: 3 russpang User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to russpang Send a message via Yahoo to russpang
Like I said - post your code. HOw do you know you are "getting nothing"??

Do you mean your query isn't working?

Response.write your output (always)

response.write (" my output is: " & request.form("reportTo") & "")

post what you get

Reply With Quote
  #5  
Old November 5th, 2003, 03:45 PM
Tyssen Tyssen is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Brisbane
Posts: 129 Tyssen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 31 m 55 sec
Reputation Power: 6
I know I'm getting nothing because what I wrote above IS the result of a response.write.

I'm using the following code to collect the information, write out the results and add the record to the database (there's a response.redirect at the end which I've left out for the purposes of printing out the output):

Code:
Set rsRep = Server.CreateObject("ADODB.Recordset")
	sqlRep = "SELECT * FROM reports"
	rsRep.CursorType = 2
	rsRep.LockType = 3
	rsRep.Open sqlRep, conn
	rsRep.Addnew
	
	For Each item in Request.Form 
	    If Request.Form(item).Count = 1 Then%>
	    <B><% = item %></B> = <% = Request.Form(item) %><BR>
	    <%
	        if Request.Form(item) = "" Then        
	            rsRep(item) = " " 
	        Else
	            rsRep(item) = Request.Form(item) 
	        End If
	     End If    
	Next
	rsRep.Update 
	rsRep.Close
	Set rsRep = Nothing


When I click on just one of the checkboxes, I get:

repPcode = H10
repPhone =
errors =
reportDate = 11/6/2003
repCreator = 3
reporter =
repEmail =
reportTo = John (or Rob or whatever name I click on)
reportQual = producer
comments =
fixDate =
carNo =


If I click on any more than one, I get:

repPcode = H10
repPhone =
errors =
reportDate = 11/6/2003
repCreator = 3
reporter =
repEmail =
reportQual = producer
comments =
fixDate =
carNo =


The reportTo = line isn't there in the second one.

The other fields are all blank because I didn't bother filling them out to create this sample output.

Reply With Quote
  #6  
Old November 6th, 2003, 07:23 AM
russpang russpang is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Location: Florida
Posts: 3 russpang User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to russpang Send a message via Yahoo to russpang
You've written in your code to look for only form fields that contain 1 entry:

If Request.Form(item).Count = 1

You have not given an "else" statement for items with multiple values.

Try changing:
If Request.Form(item).Count = 1

to

If Request.Form(item).Count > 0

Do that and you'll see your values.

Reply With Quote
  #7  
Old November 6th, 2003, 07:40 AM
Vlince Vlince is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Canada, Quebec, Montreal
Posts: 410 Vlince User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6

Reply With Quote
  #8  
Old November 6th, 2003, 03:45 PM
Tyssen Tyssen is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Brisbane
Posts: 129 Tyssen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 31 m 55 sec
Reputation Power: 6
Thumbs up

Thanks Russ, that did it. It's always the little things isn't it?

Thanks for the articles too, Vlince.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Multiple checkbox only passing one value


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT