Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Dynamically adding second address?

    Hi, is it possible to dynamically add a second address to a form if the customer clicks on a check box stating he would like his order sent to a different address? I would like this to be added dynamically, only when he clicks.

    What would I need to type, or where would I need to search?
    Thanks for any info.

    best wishes,
    AlldaRon

  • #2
    Regular Coder
    Join Date
    Jul 2005
    Posts
    116
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It's much easier to already have the second address in the form but hidden with a CSS style of "display: none" then change that to "display: block" when they click on the checkbox.

    Code:
    <html>
     <body>
      <div>
      (Shipping Address Goes Here)
      <br />
      <input type="checkbox" onclick="document.getElementById('shipping_address').style.display = this.checked ? 'block' : 'none';" /> Ship To A Different Address
      </div>
      <div id="shipping_address" style="display:none">
       (Shipping Address Goes Here)
      </div>
     </body>
    </html>

  • #3
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Awesome!

    Thanks, that worked like a charm!

    One more question, how would I make it that the price at the end changes dynamically due to the person selecting an item from multiple pull down menus?

    One menu has 4 options, each the same price, but different color.
    Now if someone pulls down on the first menu and selects a color, the price at the bottom changes to $50 price. Then they also click the "order another one" check box (from earlier question) which "unhides" another pull down menu and they select another color, which changes the price at the bottom to $100.

    Thanks in advance.

    AlldaRon
    Last edited by mrwest; 09-27-2005 at 02:22 AM.

  • #4
    Regular Coder
    Join Date
    Jul 2005
    Posts
    116
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    <html>
     <head>
      <script type="text/javascript">
    function checkColors()
    {
        var price = 0.0;
    
        if (document.getElementById('color.1').selectedIndex > 0)
        {
            price += 50.0;
    
            if (document.getElementById('color.2').selectedIndex > 0)
                price += 50.0;
        }
        else
        {
            document.getElementById('secondColorCheckbox').checked = false;
            document.getElementById('secondColor').style.display = 'none';
        }
    
        var element = document.getElementById('price');
    
        element.replaceChild(document.createTextNode('$' + price.toFixed(2)), element.firstChild);
    }
      </script>
     </head>
     <body>
      <div>
       <label for="color.1">Select A Color:
       <select id="color.1" onchange="checkColors();">
        <option value=""></option>
        <option value="red">Red</option>
        <option value="green">Green</option>
        <option value="blue">Blue</option>
       </select>
       <br />
       <input id="secondColorCheckbox" type="checkbox" onclick="document.getElementById('secondColor').style.display = this.checked ? 'block' : 'none';" /> <label for="secondColorCheckbox">Order Another One</label>
      </div>
      <div id="secondColor" style="display:none">
       <label for="color.2">Select Another Color:
       <select id="color.2" onchange="checkColors();">
        <option value=""></option>
        <option value="red">Red</option>
        <option value="green">Green</option>
        <option value="blue">Blue</option>
       </select>
      </div>
      Price: <span id="price">$0.00</span>
     </body>
    </html>

  • #5
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thank you again very much!

    Wow, that's awesome. Thanks again. Have a great week.

    AlldaRon


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •