Community Forums 

Main Content

hidden divisions??

    Aug 02 2011 22:58:14

    #1

    Debbie Q

    Join date : 2008-09-18      Posts : 4990

    Hey GT or Geoff (or anyone else) How can I make it so a divison is hidden in a form unless a certain selection is picked from a menu? Like this form but with a drop down menu instead.

    http://www.malsforms.com/multi-dropdown.html

    Debbie Q

    Mal's Support: www.mals-e.com/support.php
    GT's Forms and examples: www.malsforms.com
    Helpful java scripts: www.gemasana.com/mals
    Shipping help documents: www.stoner.org.uk/mals

    My Create-A-Book Publishing - mycreateabook.com
    Personalized Books, Music CDs and Gifts for all ages and occasions.

    Please help me out and share my site on your networks.




    Aug 03 2011 00:28:45

    #2

    Cousin Jack

    Join date : 2011-07-21      Posts : 20

    Maybe this could help? I've used this javascript to great success!

    http://www.quirksmode.org/dom/usableforms.html

    Hope it helps.

    :)



    Aug 03 2011 01:00:35

    #3

    Debbie Q

    Join date : 2008-09-18      Posts : 4990

    Thanks Jack. Looks like a pretty complicated script. It works but hopefully there is an easier way??

    Debbie Q

    Mal's Support: www.mals-e.com/support.php
    GT's Forms and examples: www.malsforms.com
    Helpful java scripts: www.gemasana.com/mals
    Shipping help documents: www.stoner.org.uk/mals

    My Create-A-Book Publishing - mycreateabook.com
    Personalized Books, Music CDs and Gifts for all ages and occasions.

    Please help me out and share my site on your networks.




    Aug 03 2011 08:41:25

    #4

    GT

    Join date : 2008-09-18      Posts : 3202

    Having trouble with a form or need one building?
    Fast turnaround, but I do charge :)

    Mal's Forms / Scripts and the syntax are here.




    Aug 03 2011 12:17:52

    #5

    Alan

    Join date : 2008-09-18      Posts : 2945

    This may be more what you had in mind to show a div - it needs more to hide them.

    <script type="text/javascript">
    function show(list){
    divid = "div"+list.selectedIndex
    document.getElementById(divid).style.display=""
    }
    </script>


    Then your dropdown
    <select name="product" onchange="show(this)">
    <option selected> -- Select A Product --</option>
    <option value="Product One">Product One</option>
    <option value="Product Two">Product Two</option>
    <option value="Product Three">Product Three</option>
    </select>

    and your divs

    <div id="div1" style="display:none">
    <input type="hidden" name="qty1" value="1" />
    <select name="productpr1">
    <option value="Product One, Type One :13.00">Product One, Type One $13.00</option>
    <option value="Product One, Type Two :15.00">Product One, Type Two $15.00</option>
    <option value="Product One, Type Three :17.00">Product One, Type Three $17.00</option>
    </select>
    </div>

    etc..

    P.S. Every time I edit, the script vanishes!

    Alan
    Some shipping help documents are available at www.stoner.org.uk/mals/




    Aug 03 2011 13:20:02

    #6

    Debbie Q

    Join date : 2008-09-18      Posts : 4990

    GT, Isn't that the same script Captain Jack.... oooppps Cousin Jack showed me?

    Alan, Thank you. Definately more what I had in mind. Simple and sweet. :)

    Debbie Q

    Mal's Support: www.mals-e.com/support.php
    GT's Forms and examples: www.malsforms.com
    Helpful java scripts: www.gemasana.com/mals
    Shipping help documents: www.stoner.org.uk/mals

    My Create-A-Book Publishing - mycreateabook.com
    Personalized Books, Music CDs and Gifts for all ages and occasions.

    Please help me out and share my site on your networks.




    Aug 03 2011 14:51:15

    #7

    Alan

    Join date : 2008-09-18      Posts : 2945

    Let's hope you don't need it more than once on a page. That would need sophistication and I spent long enough getting this far!

    Alan
    Some shipping help documents are available at www.stoner.org.uk/mals/




    Aug 03 2011 15:05:00

    #8

    Debbie Q

    Join date : 2008-09-18      Posts : 4990

    Nope Alan, This will work fine. "Sophistication" is probably what makes that other script so huge. Hopefully yours will work cross browser. Haven't checked that yet. Thanks again.

    Debbie Q

    Mal's Support: www.mals-e.com/support.php
    GT's Forms and examples: www.malsforms.com
    Helpful java scripts: www.gemasana.com/mals
    Shipping help documents: www.stoner.org.uk/mals

    My Create-A-Book Publishing - mycreateabook.com
    Personalized Books, Music CDs and Gifts for all ages and occasions.

    Please help me out and share my site on your networks.




    Aug 04 2011 08:08:22

    #9

    Alan

    Join date : 2008-09-18      Posts : 2945

    If the customer changes his mind, this hides the other div.

    Set all to no show, then one to show.

    <script type="text/javascript">
    function show(list){
    for(var i=1;i<list.length;i++){
    divid = "div"+i
    document.getElementById(divid).style.display='none';
    }
    divid = "div"+list.selectedIndex
    document.getElementById(divid).style.display=""
    };
    </script>

    Which could be written
    <script type="text/javascript">
    function show(list){
    for(var i=1;i<list.length;i++){
    divid = "div"+i
    document.getElementById(divid).style.display=i==list.selectedIndex?'block': 'none';
    }
    };
    </script>

    Alan
    Some shipping help documents are available at www.stoner.org.uk/mals/




    Aug 04 2011 16:12:05

    #10

    Debbie Q

    Join date : 2008-09-18      Posts : 4990

    Thank's Alan. I will add this change. :)

    Debbie Q

    Mal's Support: www.mals-e.com/support.php
    GT's Forms and examples: www.malsforms.com
    Helpful java scripts: www.gemasana.com/mals
    Shipping help documents: www.stoner.org.uk/mals

    My Create-A-Book Publishing - mycreateabook.com
    Personalized Books, Music CDs and Gifts for all ages and occasions.

    Please help me out and share my site on your networks.