Forum Home
Press F1
 
Thread ID: 91937 2008-07-23 08:32:00 How to select 2 commands at once in HTML? mzee (3324) Press F1
Post ID Timestamp Content User
691406 2008-07-24 10:19:00 This works if I tick both box's, but comes up with an error & will not self-tick the 2nd box.



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

<HTML>
<HEAD>
<TITLE>Untitled</TITLE>
<script language="javascript">
function CheckBothCheckboxes() {
if (document.freight.shipping.checked) {
document.freight.shipping2.checked = true;
}
}
</script>

</HEAD>

<BODY>
<TABLE style="font-family: Arial; font-size: 10pt; font-weight: bold" width="242"> <TR> <TD colspan=2 ALIGN="LEFT" width="234"><font color="#0000FF"><b><font size="2">&nbsp;NZ$ 550.00 + Freight.</font></b></font><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<IMG SRC="visa.gif" WIDTH=77 HEIGHT=31 BORDER=0 ALT="Visa and Master Card">
<br>
Please tick 2 boxes in the same row.<br>
For your shipping Area.
<form target="paypal" action="www.paypal.com method="post"></TD> </TR> <tr><td VALIGN="TOP" width="134">

<TABLE>
<TR>
<TD><name="freight">
<input type="checkbox" name="shipping" value="10.00" onClick="CheckBothCheckboxes()">
</TD>
<TD><input type="checkbox" name="shipping2" value="5.00"><FONT SIZE="-1"><B>Auckland</B></FONT></TD>
</TR>
<TR>
<TD><!--Ditto Waikato--></TD>
<TD></TD>
</TR>
<TR>
<TD><!--Ditto Wellington--></TD>
<TD></TD>
</TR>
<TR>
<TD><!--Ditto Christchurch--></TD>
<TD></TD>
</TR>
</TABLE>

<TABLE CELLSPACING=0 CELLPADDING=1 BORDER=0>
<TR>
<TD><font face="Arial" size="2"><B>Quantity</B></font></TD>
<TD><input type="text" size="1" maxlength="4" name="quantity" value="1"> </TD>
</TR>
</TABLE>
</td></tr><TD width=134 VALIGN="TOP" ALIGN="RIGHT"><input type="image" src= "submit.jpg""www.paypal.com border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
<img alt="" border="0" src="www.paypal.com width="1" height="1">
<input type="hidden" name="add" value="1">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="sales@xxxxxxxxxx.co.nz">
<input type="hidden" name="item_name" value="Enviromower">
<input type="hidden" name="item_number" value="En24v">
<input type="hidden" name="amount" value="550.00">
<input type="hidden" name="page_style" value="PayPal">
<input type="hidden" name="no_shipping" value="2">
<input type="hidden" name="return" value="http://www.xxxxxxx.co.nz">
<input type="hidden" name="currency_code" value="NZD">
<input type="hidden" name="lc" value="NZ">
<input type="hidden" name="bn" value="PP-ShopCartBF">
</form>
</TD><TD VALIGN="TOP" ALIGN="LEFT" width="94"><form target="paypal" action="www.paypal.com method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="sales@xxxxxxx.co.nz">
<input type="image" src="cart.jpg""www.paypal.com border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
<input type="hidden" name="display" value="1">
<input type="hidden" name="page_style" value="PayPal">
</form></TD></TABLE>


</BODY>
</HTML>
mzee (3324)
691407 2008-07-25 01:05:00 Your HTML has errors and is not well formed.

What I have done is just cleaned it up slightly, eg. removed the duplicate form tag, and some other invalid markup



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

<HTML>
<HEAD>
<TITLE>Untitled</TITLE>
<script language="javascript">
function CheckBothCheckboxes() {
if (document.freightform.shipping.checked) {
document.freightform.shipping2.checked = true;
}
}
</script>

</HEAD>
<BODY>
<form name="freightform" target="paypal" action="www.paypal.com method="post">
<TABLE style="font-family: Arial; font-size: 10pt; font-weight: bold" width="242">
<TR>
<TD colspan=2 ALIGN="LEFT" width="234">
<font color="#0000FF"><b><font size="2">&nbsp;NZ$ 550.00 + Freight.</font></b></font>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<IMG SRC="visa.gif" WIDTH=77 HEIGHT=31 BORDER=0 ALT="Visa and Master Card">
<br>
Please tick 2 boxes in the same row. <br>
For your shipping Area.

</TD>
</TR>
<tr>
<td VALIGN="TOP" width="134">
<TABLE>
<TR>
<TD>
<input type="checkbox" name="shipping" value="10.00" onClick="CheckBothCheckboxes()">
</TD>
<TD> <input type="checkbox" name="shipping2" value="5.00"><FONT SIZE="-1"><B>Auckland</B></FONT> </TD>
</TR>
<TR>
<TD><!--Ditto Waikato--> </TD>
<TD> </TD>
</TR>
<TR>
<TD><!--Ditto Wellington--> </TD>
<TD> </TD>
</TR>
<TR>
<TD><!--Ditto Christchurch--> </TD>
<TD> </TD>
</TR>
</TABLE>
<TABLE CELLSPACING=0 CELLPADDING=1 BORDER=0>
<TR>
<TD><font face="Arial" size="2"><B>Quantity</B></font> </TD>
<TD><input type="text" size="1" maxlength="4" name="quantity" value="1"> </TD>
</TR>
</TABLE>
</td>
</tr>
<tr>
<TD width=134 VALIGN="TOP" ALIGN="RIGHT">
<input type="image" src= "submit.jpg""www.paypal.com border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
<img alt="" border="0" src="www.paypal.com width="1" height="1">
<input type="hidden" name="add" value="1">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="sales@xxxxxxxxxx.co.nz">
<input type="hidden" name="item_name" value="Enviromower">
<input type="hidden" name="item_number" value="En24v">
<input type="hidden" name="amount" value="550.00">
<input type="hidden" name="page_style" value="PayPal">
<input type="hidden" name="no_shipping" value="2">
<input type="hidden" name="return" value="http://www.xxxxxxx.co.nz">
<input type="hidden" name="currency_code" value="NZD">
<input type="hidden" name="lc" value="NZ">
<input type="hidden" name="bn" value="PP-ShopCartBF">
</TD>
</tr>
</TABLE>
</form>
</BODY>
</HTML>
dyewitness (9398)
691408 2008-07-25 05:03:00 Nicely cleaned up there DW :)

mzee - you know the user could still un-check one of the boxes after they both are checked eh

and you could just as easy make it so both become checked no matter which one is clicked by the user ;)



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

<HTML>
<HEAD>
<TITLE>Untitled</TITLE>
<script language="javascript">
function CheckBothCheckboxes() {
if (document.freightform.shipping.checked) {
document.freightform.shipping2.checked = true;
}
}
</script>

<script language="javascript">
function CheckBothCheckboxes2() {
if (document.freightform.shipping2.checked) {
document.freightform.shipping.checked = true;
}
}
</script>


</HEAD>
<BODY>
<form name="freightform" target="paypal" action="www.paypal.com method="post">
<TABLE style="font-family: Arial; font-size: 10pt; font-weight: bold" width="242">
<TR>
<TD colspan=2 ALIGN="LEFT" width="234">
<font color="#0000FF"><b><font size="2">&nbsp;NZ$ 550.00 + Freight.</font></b></font>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<IMG SRC="visa.gif" WIDTH=77 HEIGHT=31 BORDER=0 ALT="Visa and Master Card">
<br>
Please tick 2 boxes in the same row. <br>
For your shipping Area.

</TD>
</TR>
<tr>
<td VALIGN="TOP" width="134">
<TABLE>
<TR>
<TD>
<input type="checkbox" name="shipping" value="10.00" onClick="CheckBothCheckboxes()">
</TD>
<TD> <input type="checkbox" name="shipping2" onClick="CheckBothCheckboxes2()" value="5.00"><FONT SIZE="-1"><B>Auckland</B></FONT> </TD>
</TR>
<TR>
<TD> <!--Ditto Waikato--> </TD>
<TD> </TD>
</TR>
<TR>
<TD> <!--Ditto Wellington--> </TD>
<TD> </TD>
</TR>
<TR>
<TD> <!--Ditto Christchurch--> </TD>
<TD> </TD>
</TR>
</TABLE>
<TABLE CELLSPACING=0 CELLPADDING=1 BORDER=0>
<TR>
<TD> <font face="Arial" size="2"><B>Quantity</B></font> </TD>
<TD> <input type="text" size="1" maxlength="4" name="quantity" value="1"> </TD>
</TR>
</TABLE>
</td>
</tr>
<tr>
<TD width=134 VALIGN="TOP" ALIGN="RIGHT">
<input type="image" src= "submit.jpg""www.paypal.com border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
<img alt="" border="0" src="www.paypal.com width="1" height="1">
<input type="hidden" name="add" value="1">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="sales@xxxxxxxxxx.co.nz">
<input type="hidden" name="item_name" value="Enviromower">
<input type="hidden" name="item_number" value="En24v">
<input type="hidden" name="amount" value="550.00">
<input type="hidden" name="page_style" value="PayPal">
<input type="hidden" name="no_shipping" value="2">
<input type="hidden" name="return" value="http://www.xxxxxxx.co.nz">
<input type="hidden" name="currency_code" value="NZD">
<input type="hidden" name="lc" value="NZ">
<input type="hidden" name="bn" value="PP-ShopCartBF">
</TD>
</tr>
</TABLE>
</form>
</BODY>
</HTML>
bevy121 (117)
691409 2008-07-25 05:59:00 You guys are brilliant! Works a treat, select either box & they both tick.

If I could make the second box invisible it would be less confusing maybe? Is this possible?

Thanks again.
mzee (3324)
691410 2008-07-25 06:35:00 Ooops! I spoke too soon!

It only works with one pair of checkbox's.
As soon as you enter another pair, it stops working, only ticks one box. Problem is all box;s have the same names, "shipping" or "shipping2" so it gets confused.
Any way of placing an entry in the field to use as ID so that it does not use the name= ?
mzee (3324)
691411 2008-07-25 10:18:00 Right then - this is the reply from your earlier post about having the second checkbox hidden

This code will now do that, and will also set the shipping2 value to "5" if the user checks the visible "10.00" checkbox, and reset the shipping2 back to "0" if it is unchecked again



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

<HTML>
<HEAD>
<TITLE>Untitled</TITLE>

<script language="javascript">
function CheckBothCheckboxes() {
if (document.freightform.shipping.checked == true) {
document.freightform.shipping2.value = "5.00";
}
if (document.freightform.shipping.checked == false) {
document.freightform.shipping2.value = "0";
}
}
</script>


</HEAD>
<BODY>
<form name="freightform" target="paypal" action="www.paypal.com method="post">
<TABLE style="font-family: Arial; font-size: 10pt; font-weight: bold" width="242">
<TR>
<TD colspan=2 ALIGN="LEFT" width="234">
<font color="#0000FF"><b><font size="2">&nbsp;NZ$ 550.00 + Freight.</font></b></font>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<IMG SRC="visa.gif" WIDTH=77 HEIGHT=31 BORDER=0 ALT="Visa and Master Card">
<br>
Please tick 2 boxes in the same row. <br>
For your shipping Area.

</TD>
</TR>
<tr>
<td VALIGN="TOP" width="134">
<TABLE>
<TR>
<TD>
<input type="checkbox" name="shipping" value="10.00" onClick="CheckBothCheckboxes()"><FONT SIZE="-1"><B>Auckland</B></FONT>
</TD>
<TD>
<input type="hidden" name="shipping2" value="0">
</TD>
</TR>
<TR>
<TD> <!--Ditto Waikato--> </TD>
<TD> </TD>
</TR>
<TR>
<TD> <!--Ditto Wellington--> </TD>
<TD> </TD>
</TR>
<TR>
<TD> <!--Ditto Christchurch--> </TD>
<TD> </TD>
</TR>
</TABLE>
<TABLE CELLSPACING=0 CELLPADDING=1 BORDER=0>
<TR>
<TD> <font face="Arial" size="2"><B>Quantity</B></font> </TD>
<TD> <input type="text" size="1" maxlength="4" name="quantity" value="1"> </TD>
</TR>
</TABLE>
</td>
</tr>
<tr>
<TD width=134 VALIGN="TOP" ALIGN="RIGHT">
<input type="image" src= "submit.jpg""www.paypal.com border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
<img alt="" border="0" src="www.paypal.com width="1" height="1">
<input type="hidden" name="add" value="1">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="sales@xxxxxxxxxx.co.nz">
<input type="hidden" name="item_name" value="Enviromower">
<input type="hidden" name="item_number" value="En24v">
<input type="hidden" name="amount" value="550.00">
<input type="hidden" name="page_style" value="PayPal">
<input type="hidden" name="no_shipping" value="2">
<input type="hidden" name="return" value="http://www.xxxxxxx.co.nz">
<input type="hidden" name="currency_code" value="NZD">
<input type="hidden" name="lc" value="NZ">
<input type="hidden" name="bn" value="PP-ShopCartBF">
</TD>
</tr>
</TABLE>
</form>
</BODY>
</HTML>



Let me think about the other checkbox sets you have.
You do of course need to name them all different - their own unique name.
And each Form name is unique as well, as thats how you "call" them with javascript.

How many sets of checkboxes is there?
bevy121 (117)
691412 2008-07-25 10:33:00 I have to say I believe you should be using radio buttons but I don't really get what is going on here so I could be wrong. sal (67)
691413 2008-07-25 10:50:00 yea - it is getting a bit confusing now LOL

I did suggest radio buttons earlier and now think that is probably the way it should be...


mzee - can you tell me what you want to end up with exactly?

Do you want the value of "shipping2" to be 5.00 if any of the locations are selected at all, or is this number to be variable too, depending on the location selected?
bevy121 (117)
691414 2008-07-26 02:32:00 There are 4 pairs of check box's, each pair represents a different freight rate area. The first box sets name="shipping" value="10.00" (amount varies depending on weight, location etc)
The second box sets name="shipping2" value="5.00" (lower freight rate on multiple orders. This varies as well)

The form works OK as it is with manual ticking of the box's, but if a customer forgets to tick the second box he will only be charged freight for the first item.

The idea is to 'lock' each pair together so that when one is ticked, they both tick. This, thanks to you all, has now been achieved. Only problem is as soon as there is more than one pair of box's it stops working! I think the problem is because the same 'names' are used for each pair. Is there a way of identifying the check box apart from the 'name'?
We could then have multiple scripts for each pair of box's
Radio buttons would not do as only one selection could be made, & the same problem would apply.
mzee (3324)
691415 2008-07-26 02:39:00 This is the part of the form which works as it is.

<TABLE style="font-family: Arial; font-size: 10pt; font-weight: bold" width="242"> <TR> <TD colspan=2 ALIGN="LEFT" width="234"><font color="#0000FF"><b><font size="2">&nbsp;NZ$ 550.00 + Freight.</font></b></font><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<IMG SRC="visa.gif" WIDTH=77 HEIGHT=31 BORDER=0 ALT="Visa and Master Card">
<br>
Please tick 2 boxes in the same row. <br>
For your shipping Area.
<form target="paypal" action="www.paypal.com method="post"></TD> </TR> <tr><td VALIGN="TOP" width="134"><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=1>
<TR>
<td><font face="Arial" size="2"><b>Auckland:</b></font></TD>
<td>
<input type="checkbox" name="shipping" value="5.00"></TD>
<td> <input type="checkbox" name="shipping2" value="5.00"></TD>
</TR>
<TR>
<td><font face="Arial" size="2"><b>Waikato:</b></font></TD>
<td> <input type="checkbox" name="shipping" value="10.00"></TD>
<td> <input type="checkbox" name="shipping2" value="8.00"></TD>
</TR>
<TR>
<td><font face="Arial" size="2"><b>Wellington:&nbsp;</b></font></TD>
<td> <input type="checkbox" name="shipping" value="15.00"></TD>
<td> <input type="checkbox" name="shipping2" value="10.00"></TD>
</TR>
<TR>
<td><font face="Arial" size="2"><b>Christchurch:</b></font></TD>
<td> <input type="checkbox" name="shipping" value="20.00"></TD>
<td> <input type="checkbox" name="shipping2" value="15.00"></TD>
</TR>
</TABLE> <TABLE CELLSPACING=0 CELLPADDING=1 BORDER=0>
<TR>
<TD><font face="Arial" size="2"><B>Select Quantity</B></font></TD>
<TD><input type="hidden" name="quantity" value=""><select name="quantity" >
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option></select></TD>
</TR>
</TABLE>
mzee (3324)
1 2 3