| 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 | ||
| 691396 | 2008-07-23 08:32:00 | I am using PayPal on a web site. Problem is that if I wish to select 2 freight rates, I have to select twice to do it. How can I select once:- <TR> <td><font face="Arial" size="2"><b>Auckland:</b></font></TD> <td> <input type="checkbox" name="shipping" value="10.00"></TD> <td><input type="checkbox" name="shipping2" value="5.00"></TD> </TR> How can I combine the two Inputs to be controlled by one action (tick, radio, button, select-option)? I have tried all sorts but when you put them together only the first one works.:help: |
mzee (3324) | ||
| 691397 | 2008-07-23 08:38:00 | Maybe I should explain why both are required at the same time. "shipping" is the rate which is charged for the first item. "shipping2" is a reduced rate charged on subsequent purchases of the same item. The selection is required to cover different areas within New Zealand. |
mzee (3324) | ||
| 691398 | 2008-07-23 10:03:00 | Not sure what you want to do there mzee? The 'value' of "5.00" and "10.00" you have set are not integer values (numbers) they are the text representaion, so you can't "add" them together (if that's what you were wanting to do) I could be wrong, but I think that is the case |
bevy121 (117) | ||
| 691399 | 2008-07-24 04:17:00 | You are right- they are text values:- <TR> <td> <font face="Arial" size="2"><b>Auckland:</b></font></TD> <td> <input type="checkbox" name="shipping" value="10.00" ></TD> <td> <input type="checkbox" name="shipping2" value="5.00"></TD> </TR> By adding I mean to have the name="shipping" value="10.00" and the name="shipping2" value="5.00" in one input instead of two. Something like: <input type="checkbox" name="shipping" value="10.00" name="shipping2" value="5.00">. This does not work, only gets the first name="shipping" If I could somehow link both checkbox's so one tick would suffice? |
mzee (3324) | ||
| 691400 | 2008-07-24 04:50:00 | Multiple choice - use checkbox type input <form name="myform" action="www.mydomain.com method="POST"> <div align="center"><br> <input type="checkbox" name="shipping" value="10.00" checked>First item shipping<br> <input type="checkbox" name="shipping2" value="5.00" > Subsequent items shipping<br> <br> </div> </form> Exclusive single choice only - use radio buttons input <form name="myform" action="www.mydomain.com method="POST"> <div align="center"><br> <input type="radio" name="shipping" value="10.00" > First item shipping<br> <input type="radio" name="shipping" value="5.00" checked> Subsequent items shipping<br> </div> With this type the input name (shipping) remains constant for all options no matter how many. (because there can only be one value returned) When read, the "shipping" value will reflect the users choice - either 10.00 or 5.00 Does that make sense to you? |
bevy121 (117) | ||
| 691401 | 2008-07-24 05:11:00 | The double checkbox works fine, because there has to be 2 values with 2 names, name="shipping" & name="shipping2". What I need is a way of activating both statements with one physical action instead of two. Picture a dual pole switch ie. 2 circuits with one lever :nerd: |
mzee (3324) | ||
| 691402 | 2008-07-24 05:39:00 | Still a bit confusing what you are asking for, but anyway this bit of javascript will check both checkbox if you click the first one. What is processing the form once it's submitted, is this in your control, or does it just get submitted through to paypal? <html> <head> <script language="javascript"> function CheckBothCheckboxes() { if (document.form1.checkbox1.checked) { document.form1.checkbox2.checked = true; } } </script> </head> <body> <form name="form1" action="#" method="post"> <input type="checkbox" name="checkbox1" value="10" onClick="CheckBothCheckboxes()">checkbox1: 10 <br> <input type="checkbox" name="checkbox2" value="5">checkbox2: 5 <br> <input type="submit"> </form> </body> </html> |
dyewitness (9398) | ||
| 691403 | 2008-07-24 06:59:00 | I will try it. The form gets submitted to PayPal and works well, its just that customers are less likely to forget to tick one than both. If the second one is not ticked they only get charged freight on one item. Maybe I can put <input type="hidden" name="shipping2" value="10.00"> in before the selection, it would then be true if the second box was not ticked, better than nothing! Will try the script. |
mzee (3324) | ||
| 691404 | 2008-07-24 07:54:00 | Tried the script. Error "document.form1.shipping.is null or not an object" I am trying to place this in an existing form, so don't know what to do with the: <form name="form1" action="#" method="post"> <input type="submit"> Will keep trying :crying |
mzee (3324) | ||
| 691405 | 2008-07-24 08:37:00 | Can you post the exact HTML of your form? (the previous post was just an example, it will need to be tweaked to match your checkbox names etc). |
dyewitness (9398) | ||
| 1 2 3 | |||||