|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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? |
|
#2
|
|||
|
|||
|
Can you post your output?
|
|
#3
|
|||
|
|||
|
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. |
|
#4
|
|||
|
|||
|
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 |
|
#5
|
|||
|
|||
|
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. |
|
#6
|
|||
|
|||
|
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. |
|
#7
|
|||
|
|||
|
Or read these two articles:
http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=153 and http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=141 Hope this helps! Sincerely Vlince |
|
#8
|
|||
|
|||
|
Thanks Russ, that did it. It's always the little things isn't it?
Thanks for the articles too, Vlince. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > Multiple checkbox only passing one value |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|