Page 1 of 3 123 LastLast
Results 1 to 10 of 30
  1. #1
    Member mzee's Avatar
    Join Date
    Dec 2004
    Posts
    2,428

    Default How to select 2 commands at once in HTML?

    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.

  2. #2
    Member mzee's Avatar
    Join Date
    Dec 2004
    Posts
    2,428

    Default Re: How to select 2 commands at once in HTML?

    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.

  3. #3
    Senior Member
    Join Date
    Nov 2006
    Posts
    1,923

    Default Re: How to select 2 commands at once in HTML?

    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

  4. #4
    Member mzee's Avatar
    Join Date
    Dec 2004
    Posts
    2,428

    Question Re: How to select 2 commands at once in HTML?

    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?

  5. #5
    Senior Member
    Join Date
    Nov 2006
    Posts
    1,923

    Default Re: How to select 2 commands at once in HTML?

    Multiple choice - use checkbox type input

    Code:
    <form name="myform" action="http://www.mydomain.com/myformhandler.cgi" 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

    Code:
    <form name="myform" action="http://www.mydomain.com/myformhandler.cgi" 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?
    Last edited by bevy121; 24-07-2008 at 04:53 PM.

  6. #6
    Member mzee's Avatar
    Join Date
    Dec 2004
    Posts
    2,428

    Smile Re: How to select 2 commands at once in HTML?

    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

  7. #7
    Senior Member
    Join Date
    May 2008
    Location
    Auckland
    Posts
    186

    Default Re: How to select 2 commands at once in HTML?

    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?

    Code:
    <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>

  8. #8
    Member mzee's Avatar
    Join Date
    Dec 2004
    Posts
    2,428

    Default Re: How to select 2 commands at once in HTML?

    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.

  9. #9
    Member mzee's Avatar
    Join Date
    Dec 2004
    Posts
    2,428

    Default Re: How to select 2 commands at once in HTML?

    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

  10. #10
    Senior Member
    Join Date
    May 2008
    Location
    Auckland
    Posts
    186

    Default Re: How to select 2 commands at once in HTML?

    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).