|
-
Dec 19th, 2003, 03:45 AM
#1
Thread Starter
Hyperactive Member
dealing with multiple check boxes
I'm pulling back a list of results whcih will include a checkbox, a listbox and a textbox.
The idea is the user will tick rows that he wants an action performed, select the general reason from the listbox and write more specific information in the texbox.
The user will be able to tick etc multiple rows befoer clicking submit.
The problem is i'm not sure how to deal with submitting values for multiple rows. i don't know how i'll be able to say.
'ok this row was ticked and this value selected from the list box and this text entered in the textbox, and then this row was selected with this value selected from the listbox and this text entered in the textbox' etc etc
-
Dec 19th, 2003, 03:58 AM
#2
Fanatic Member
pull them all through in the next stage and create an array. Then lop through with an if statement to see if there ticked
-
Dec 19th, 2003, 05:15 AM
#3
Thread Starter
Hyperactive Member
thanks for the reply davebat.
i've tried doing the following. i've managed to determine and
display whether the checkbox on a row is selected. (i think)
but i also want to try and display the selection from the listbox and the textbox. but i'm not sure how to.
Code:
dim TransferItemID
dim IsSelected
for each TransferItemID in Request.form
IsSelected = (Request.form(TransferItemID).count = 3)
if IsSelected then
response.write TransferItemID & " is selected " & IsSelected & "<br>"
else
response.write TransferItemID & " is not selected " & IsSelected & "<br>"
end if
next
-
Dec 19th, 2003, 10:10 AM
#4
This thread might help. I have provided a solution in this thread a while back.
Have a look...
http://www.vbforums.com/showthread.p...ghlight=danial
[VBF RSS Feed]
There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.
If I have been helpful, Please Rate my Post. Thanks.
This post was powered by : 
-
Dec 19th, 2003, 10:49 AM
#5
Thread Starter
Hyperactive Member
cheers for the reply. i've had a look at the example but it doesn't seem to be quite what i'm trying to do.
i have three controls that can have stuff entered/selected.
and when i submit i to be able to get the data for all of them where the checkbox is ticked.
-
Dec 19th, 2003, 10:52 AM
#6
Post the code of the sbmiting page and i will give you a solution. I am not exactly sure what are you having problem withs. You say you can read the value of selected items. What part is not working..
[VBF RSS Feed]
There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.
If I have been helpful, Please Rate my Post. Thanks.
This post was powered by : 
-
Dec 19th, 2003, 10:58 AM
#7
Thread Starter
Hyperactive Member
this is the stuff for the posting page
Code:
private sub ShowProductForSubCode(TransferID)
Dim RejCon
Dim RejRes
Dim RejCmd
Dim RejParam
set RejCon = CreateConnection("INTERNAL", "ilabelCustomers")
set RejRes = server.createobject("adodb.recordset")
set RejCmd = server.createobject("adodb.command")
RejCmd.commandtype = 4
RejCmd.commandtext = "spBTRGetProductToRejectByTID"
set RejParam = RejCmd.createparameter("@TransferID", 3,1)
RejCmd.parameters.append RejParam
RejParam.value = TransferID
set RejCmd.activeconnection = RejCon
set RejRes = RejCmd.execute
response.write "<center><table><form action='LogRejectedProducts.asp' method='post'><tr class='header'><th>SubCode</th><th>Ean</th><th>Product Description</th><th>Date Created</th><th>Transferid</th><th>Reject</th><th>Reason List</th><th>Specific Reason</th></tr>"
do while not RejRes.eof
response.write "<tr><td>" & RejRes.fields("smanucode").value & "</td><td>" & RejRes.fields("eancode").value & "</td><td>" & RejRes.fields("productdescription").value & "</td><td>" & RejRes.fields("datecreated").value & "</td><td>" & RejRes.fields("transferid").value & "</td><td><input type=checkbox name='" & RejRes.fields("transferitemid").value & "'>"
'POPULATE A LIST BOX AGAINST EVERY ROW, done it with separate function
response.write "</td><td>" & GetRejectionList(RejRes.fields("transferitemid").value) & "</td><td>"
response.write "<input type=text name='" & RejRes.fields("transferitemid").value & "'></td></tr>"
RejRes.movenext
loop
response.write "<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td><input type='Submit' value='Reject'></td></form></table></center>"
RejCon.close
set RejCon = nothing
set RejCmd = nothing
set RejRes = nothing
end sub
private function GetRejectionList(TransferItemID)
Dim RejCon
Dim RejRes
Dim RejCmd
Dim OptionString
set RejCon = CreateConnection("INTERNAL", "ilabelCustomers")
set RejRes = server.createobject("adodb.recordset")
set RejCmd = server.createobject("adodb.command")
RejCmd.commandtype = 4
RejCmd.commandtext = "spBTRGetRejectionList"
set RejCmd.activeconnection = RejCon
set RejRes = RejCmd.execute
OptionString = "<select name='" & TransferItemID & "'>"
do while not RejRes.eof
OptionString = OptionString & "<option selected value=" & RejRes.fields(0).value & ">" & RejRes.fields(1).value & "</option>"
RejRes.movenext
loop
GetRejectionList = OptionString
RejCon.close
set RejCon = nothing
set RejCmd = nothing
set RejRes = nothing
end function
at the moment this is all i've got for the receiving
Code:
dim TransferItemID
dim IsSelected
dim tes
for each TransferItemID in Request.form
IsSelected = (Request.form(TransferItemID).count = 3)
test = (Request.form(TransferItemID).count =6)
if IsSelected then
response.write Transfer & " is selected " & IsSelected & "<br>"
response.write test
else
response.write TransferItemID & " is not selected " & IsSelected & "<br>"
end if
next
what i want to be able to do is say.
for all checked rows display the selection from the listbox and the contents of the textbox
-
Dec 19th, 2003, 11:44 AM
#8
Thread Starter
Hyperactive Member
arrgh this is doing my head in any help would be greatly appreciated
-
Dec 19th, 2003, 11:45 AM
#9
Can you quickly pass me the generated HTML file too, that will be much easier for me, as i dont wanna go through the each asp code. Ill try to give u a solution now.
[VBF RSS Feed]
There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.
If I have been helpful, Please Rate my Post. Thanks.
This post was powered by : 
-
Dec 19th, 2003, 11:53 AM
#10
Thread Starter
Hyperactive Member
Code:
private sub ShowProductForSubCode(TransferID)
Dim RejCon
Dim RejRes
Dim RejCmd
Dim RejParam
set RejCon = CreateConnection("INTERNAL", "ilabelCustomers")
set RejRes = server.createobject("adodb.recordset")
set RejCmd = server.createobject("adodb.command")
RejCmd.commandtype = 4
RejCmd.commandtext = "spBTRGetProductToRejectByTID"
set RejParam = RejCmd.createparameter("@TransferID", 3,1)
RejCmd.parameters.append RejParam
RejParam.value = TransferID
set RejCmd.activeconnection = RejCon
set RejRes = RejCmd.execute
response.write "<center><table><form action='LogRejectedProducts.asp' method='post'><tr class='header'><th>SubCode</th><th>Ean</th><th>Product Description</th><th>Date Created</th><th>Transferid</th><th>Reject</th><th>Reason List</th><th>Specific Reason</th></tr>"
do while not RejRes.eof
response.write "<tr><td>" & RejRes.fields("smanucode").value & "</td><td>" & RejRes.fields("eancode").value & "</td><td>" & RejRes.fields("productdescription").value & "</td><td>" & RejRes.fields("datecreated").value & "</td><td>" & RejRes.fields("transferid").value & "</td><td><input type=checkbox name='" & RejRes.fields("transferitemid").value & "'>"
'POPULATE A LIST BOX AGAINST EVERY ROW, done it with separate function
response.write "</td><td>" & GetRejectionList(RejRes.fields("transferitemid").value) & "</td><td>"
response.write "<input type=text name='" & RejRes.fields("transferitemid").value & "'></td></tr>"
RejRes.movenext
loop
response.write "<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td><input type='Submit' value='Reject'></td></form></table></center>"
RejCon.close
set RejCon = nothing
set RejCmd = nothing
set RejRes = nothing
end sub
private function GetRejectionList(TransferItemID)
Dim RejCon
Dim RejRes
Dim RejCmd
Dim OptionString
set RejCon = CreateConnection("INTERNAL", "ilabelCustomers")
set RejRes = server.createobject("adodb.recordset")
set RejCmd = server.createobject("adodb.command")
RejCmd.commandtype = 4
RejCmd.commandtext = "spBTRGetRejectionList"
set RejCmd.activeconnection = RejCon
set RejRes = RejCmd.execute
OptionString = "<select name='transfer'>"
do while not RejRes.eof
OptionString = OptionString & "<option selected value=" & RejRes.fields(0).value & ">" & RejRes.fields(1).value & "</option>"
RejRes.movenext
loop
GetRejectionList = OptionString
RejCon.close
set RejCon = nothing
set RejCmd = nothing
set RejRes = nothing
end function
html for form
Code:
<html>
<head>
<link rel="stylesheet" type="text/css" href="include/styles.css">
<title>Transfered Images Available For Rejection</title>
<center>
<h2>Transfered Images Available For Rejection</h2>
</center>
</head>
<center><table><form action='LogRejectedProducts.asp' method='post'><tr class='header'><th>SubCode</th><th>Ean</th><th>Product Description</th><th>Date Created</th><th>Transferid</th><th>Reject</th><th>Reason List</th><th>Specific Reason</th></tr><tr><td>AAPP001</td><td>5000452003623</td><td>Geo Adams 20 Cooked Cocktail Pork Sausages 176g</td><td>15/12/03 12:13:00</td><td>195</td><td><input type=checkbox name='1699'></td><td><select name='1699'><option selected value=22>Rejected (Customer)</option><option selected value=21>Rejected (PH QA)</option></td><td><input type=text name='1699'></td></tr><tr><td>AAPP001</td><td>50452880</td><td>Geo Adams Lincolnshire Pork Sausages 454g</td><td>15/12/03 12:13:00</td><td>195</td><td><input type=checkbox name='1700'></td><td><select name='1700'><option selected value=22>Rejected (Customer)</option><option selected value=21>Rejected (PH QA)</option></td><td><input type=text name='1700'></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td><input type='Submit' value='Reject'></td></form></table></center>
result of ticking one box and submitting
Code:
<html>
1699 is selected True<br>1700 is not selected False<br>
</html>
-
Dec 19th, 2003, 11:57 AM
#11
I meant the generated HTML output after the posting asp page has been parsed. Just run the posting asp page in your browser and click on view source and copy and paste the html out put here.
[VBF RSS Feed]
There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.
If I have been helpful, Please Rate my Post. Thanks.
This post was powered by : 
-
Dec 19th, 2003, 11:59 AM
#12
Thread Starter
Hyperactive Member
i have, haven't i, above is the html that gen's the form and then underneath that is the results of posting the page
-
Dec 19th, 2003, 12:01 PM
#13
Originally posted by sagey
i have, haven't i, above is the html that gen's the form and then underneath that is the results of posting the page
Oops sorry, it was all in one line, and i skimme through it and missed it. Give me a while to go through the code and try to solve ur poblem. Ill get back to you.
[VBF RSS Feed]
There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.
If I have been helpful, Please Rate my Post. Thanks.
This post was powered by : 
-
Dec 19th, 2003, 12:04 PM
#14
Thread Starter
Hyperactive Member
b rilliant cheers i've got the feeling i'm doing something really daft
-
Dec 19th, 2003, 12:44 PM
#15
Ok here is the problem and a possible solution. I am sure it can be done in more then one ways, but here is my approach.
You have named all the elements(checkbox, select box, textbox) same. It would be much easier if you use the following.
Check the following in your submiting asp page.
for checkbox
name='cb" & transferitemid & "'"
for textbox
name='tb" & tranferitemid & "'"
for list box
name='lb" & transferitemid & "'"
now try out my following code, i think thats what you asked for, if not then let me know.
It will print out the value from the listbox and textbox for selected item.
VB Code:
<%
dim TransferItemID
dim IsSelected
for each TransferItemID in Request.form
IsSelected = Request.form(TransferItemID)
dim n
n=mid(transferitemid,3)
if IsSelected="on" then
response.write "TransferItemId :" & n & " "
response.write "listbox value :" & request.form ("lb" & n) & " "
response.write "textbox value :" & request.form("tb" & n ) & "<br>"
end if
next
%>
Hope this helps.
Danial
[VBF RSS Feed]
There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.
If I have been helpful, Please Rate my Post. Thanks.
This post was powered by : 
-
Dec 19th, 2003, 12:47 PM
#16
Output of the submiting file
Code:
<html>
<head>
<link rel="stylesheet" type="text/css" href="include/styles.css">
<title>Transfered Images Available For Rejection</title>
<center>
<h2>Transfered Images Available For Rejection</h2>
</center>
</head>
<center><table><form action='LogRejectedProducts.asp' method='post'>
<tr class='header'><th>SubCode</th><th>Ean</th><th>Product Description</th><th>Date Created</th>
<th>Transferid</th><th>Reject</th><th>Reason List</th><th>Specific Reason</th></tr>
<tr><td>AAPP001</td><td>5000452003623</td><td>Geo Adams 20 Cooked Cocktail Pork Sausages 176g</td>
<td>15/12/03 12:13:00</td><td>195</td><td>
<input type=checkbox name='cb1699'></td><td>
<select name='sb1699'>
<option selected value=22>Rejected (Customer)</option>
<option selected value=21>Rejected (PH QA)</option></td>
<td><input type=text name='tb1699'></td></tr><tr><td>AAPP001</td><td>50452880</td>
<td>Geo Adams Lincolnshire Pork Sausages 454g</td><td>15/12/03 12:13:00</td><td>195</td><td>
<input type=checkbox name='cb1700'></td><td><select name='sb1700'>
<option selected value=22>Rejected (Customer)</option>
<option selected value=21>Rejected (PH QA)</option></td><td>
<input type=text name='tb1700'></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>
<input type='Submit' value='Reject'></td></form></table></center>
Here is the code which will process the file
VB Code:
<%
dim TransferItemID
dim IsSelected
for each TransferItemID in Request.form
IsSelected = Request.form(TransferItemID)
dim n
n=mid(transferitemid,3)
if IsSelected="on" then
response.write "TransferItemId :" & n & " "
response.write "listbox value :" & request.form ("lb" & n) & " "
response.write "textbox value :" & request.form("tb" & n ) & "<br>"
end if
next
%>
[VBF RSS Feed]
There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.
If I have been helpful, Please Rate my Post. Thanks.
This post was powered by : 
-
Dec 22nd, 2003, 03:36 AM
#17
Thread Starter
Hyperactive Member
thanks for the reply. i think i almost get it. but i'm not sure how to go about using the
for checkbox
name='cb" & transferitemid & "'"
i don't supose you could give me a code snippet of the the form should be like?
-
Dec 22nd, 2003, 07:59 AM
#18
Here you go
VB Code:
private sub ShowProductForSubCode(TransferID)
Dim RejCon
Dim RejRes
Dim RejCmd
Dim RejParam
set RejCon = CreateConnection("INTERNAL", "ilabelCustomers")
set RejRes = server.createobject("adodb.recordset")
set RejCmd = server.createobject("adodb.command")
RejCmd.commandtype = 4
RejCmd.commandtext = "spBTRGetProductToRejectByTID"
set RejParam = RejCmd.createparameter("@TransferID", 3,1)
RejCmd.parameters.append RejParam
RejParam.value = TransferID
set RejCmd.activeconnection = RejCon
set RejRes = RejCmd.execute
response.write "<center><table><form action='LogRejectedProducts.asp' method='post'><tr class='header'><th>SubCode</th><th>Ean</th><th>Product Description</th><th>Date Created</th><th>Transferid</th><th>Reject</th><th>Reason List</th><th>Specific Reason</th></tr>"
do while not RejRes.eof
response.write "<tr><td>" & RejRes.fields("smanucode").value & "</td><td>" & RejRes.fields("eancode").value & "</td><td>" & RejRes.fields("productdescription").value & "</td><td>" & RejRes.fields("datecreated").value & "</td><td>" & RejRes.fields("transferid").value & "</td><td>
<input type=checkbox name='cb" & RejRes.fields("transferitemid").value & "'>"
'POPULATE A LIST BOX AGAINST EVERY ROW, done it with separate function
response.write "</td><td>" & GetRejectionList(RejRes.fields("transferitemid").value) & "</td><td>"
response.write "<input type=text name='tb" & RejRes.fields("transferitemid").value & "'></td></tr>"
RejRes.movenext
loop
response.write "<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>
<input type='Submit' value='Reject'></td></form></table></center>"
RejCon.close
set RejCon = nothing
set RejCmd = nothing
set RejRes = nothing
end sub
private function GetRejectionList(TransferItemID)
Dim RejCon
Dim RejRes
Dim RejCmd
Dim OptionString
set RejCon = CreateConnection("INTERNAL", "ilabelCustomers")
set RejRes = server.createobject("adodb.recordset")
set RejCmd = server.createobject("adodb.command")
RejCmd.commandtype = 4
RejCmd.commandtext = "spBTRGetRejectionList"
set RejCmd.activeconnection = RejCon
set RejRes = RejCmd.execute
OptionString = "<select name='lb" & TransferItemId & "'>"
do while not RejRes.eof
OptionString = OptionString & "<option selected value=" & RejRes.fields(0).value & ">" & RejRes.fields(1).value & "</option>"
RejRes.movenext
loop
GetRejectionList = OptionString & "</select>"
RejCon.close
set RejCon = nothing
set RejCmd = nothing
set RejRes = nothing
end function
[VBF RSS Feed]
There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.
If I have been helpful, Please Rate my Post. Thanks.
This post was powered by : 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|