|
 |
asp_web_howto thread: testing within loop
Message #1 by "Michael Goldman" <mg188@h...> on Wed, 20 Dec 2000 13:32:46 -0800
|
|
Hi, In this form, the user checks items to delete and which email
message to send about each item.
How can I force the user to check one and only one message for each deleted
item? Javascript? How? I tried using the .checked property, but that just
paused the script, and on the next click sent the user to the next page.
I'm using PWS, by the way.
With my current code, it's possible to check boxes like this:
Item Delete Msg1 Msg2
A checked checked checked
B checked
C
This would send 2 arrays to next page: Item(A,A) and Msg(msg1,msg2). On
the next page, I pair up sequential values from each array. So in the case
above, both messages get sent for Item A, and none for Item B. This would
cause problems.
I tried using radio buttons and combo boxes instead of checkboxes. They
didn't work right either.
The form code:
response.write
"<table><tr><td>Item</td><td>Delete</td><td>Msg1</td><td>Msg2</td></t
r>"
Do while not rs.eof
response.write "<tr><td>"&rs("Item")&"</td>"
response.write "<td><input type=checkbox name=Item
value='"&rs("Item")&"'></td>"
response.write "<td><input type=checkbox name=Msg value=msg1></td>"
response.write "<td><input type=checkbox name=Msg value=msg2></td></tr>"
rs.movenext
Loop
response.write "</table>
Thanks in advance
moderator: I'm resending this (cleaned up a little). Last time it was
posted to asp_forms, with no replies. Could we try asp_databases, and/or
javascript this time?
---
MaximumASP offers enhanced hosting solutions on the Windows 2000 platform. Dedicated processor, RAM, and server resources provide
dedicated server performance at virtual server prices. Commercial components provided; custom components allowed.
---
You are currently subscribed to asp_web_howto as: $subst('Recip.EmailAddr')
To unsubscribe send a blank email to leave-asp_web_howto-$subst('Recip.MemberIDChar')@p2p.wrox.com
Message #2 by Vince Kavanagh <vince@6...> on Wed, 20 Dec 2000 23:10:07 +0000
|
|
In the <HEAD> you could write;
<SCRIPT language="JavaScript">
<!--
function radioCBox (checkbox) {
var checkboxGroup = document.options.myCheck;
for (var c = 0; c < checkboxGroup.length; c++)
if (checkboxGroup[c] != checkbox)
checkboxGroup[c].checked = false;
return checkbox.checked;
}
//-->
</SCRIPT>
and then in the <BODY>;
<form name = "options">
<%
Do while not rs.eof
Response.Write("<tr><td><input TYPE='CHECKBOX' NAME='myCheck'")
Response.Write(" value='")
Response.Write(rs("item"))
Response.Write("' ONCLICK='return radioCBox(this);'")
Response.Write("></td></tr>")
rs.movenext
Loop
%>
</form>
That should do it.
Vince.
Michael Goldman wrote:
> Hi, In this form, the user checks items to delete and which email
> message to send about each item.
>
> How can I force the user to check one and only one message for each deleted
> item? Javascript? How? I tried using the .checked property, but that just
> paused the script, and on the next click sent the user to the next page.
> I'm using PWS, by the way.
>
> With my current code, it's possible to check boxes like this:
> Item Delete Msg1 Msg2
> A checked checked checked
> B checked
> C
>
> This would send 2 arrays to next page: Item(A,A) and Msg(msg1,msg2). On
> the next page, I pair up sequential values from each array. So in the case
> above, both messages get sent for Item A, and none for Item B. This would
> cause problems.
>
> I tried using radio buttons and combo boxes instead of checkboxes. They
> didn't work right either.
>
> The form code:
> response.write
>
"<table><tr><td>Item</td><td>Delete</td><td>Msg1</td><td>Msg2</td></t
r>"
> Do while not rs.eof
> response.write "<tr><td>"&rs("Item")&"</td>"
> response.write "<td><input type=checkbox name=Item
> value='"&rs("Item")&"'></td>"
> response.write "<td><input type=checkbox name=Msg value=msg1></td>"
> response.write "<td><input type=checkbox name=Msg value=msg2></td></tr>"
> rs.movenext
> Loop
> response.write "</table>
>
> Thanks in advance
---
MaximumASP offers enhanced hosting solutions on the Windows 2000 platform. Dedicated processor, RAM, and server resources provide
dedicated server performance at virtual server prices. Commercial components provided; custom components allowed.
---
You are currently subscribed to asp_web_howto as: $subst('Recip.EmailAddr')
To unsubscribe send a blank email to leave-asp_web_howto-$subst('Recip.MemberIDChar')@p2p.wrox.com
|
|
 |