Not signed in (Sign In)

Vanilla 1.1.5a is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthorsmartalex
    • CommentTimeDec 31st 2010
     
    Can someone please explain to me what is wrong with my code? I'm trying to get the "phone" div to hide when email is pressed and show when it's not. But it's always on. The instructions seem straightforward enough, but I can not get it to work.

    (Really I want the checkbox to be 3 radio buttons: phone, email, both but I can't even get this simplified version to work.)

    <head>

    <script type="text/javascript" src="wforms_core.js"></script>
    <script type="text/javascript" src="wforms_switch.js"></script>

    <style type="text/css">
    .onstate-phone { display: block; }
    .offstate-phone { display: none; }
    </style>
    </head>
    <body>

    <form name="userinfo" action="insert.php" method="post">

    How would you like us to contact you?<br>
    <input type="checkbox" name="ContactPreference" value="email" class="switch-phone" />Email
    <div class="offstate-phone">
    What time of the day would you prefer to be contacted by phone?
    <select name="TimeOfDay">
    <option value="Morning">Morning</option>
    <option value="Noon">Noon</option>
    <option value="Afternoon">Afternoon</option>
    <option value="Evening">Evening</option>
    </select>
    </div>
    <input type="Submit">
    </form>

    </body>
    • CommentAuthordbuschho
    • CommentTimeDec 31st 2010
     
    Hello,

    You had it mostly right, but you were missing a few required library files. FormAssembly's wForm library depends on the base2 library in order to overcome browser compatibilties in DOM handling. Try this code and see if it works for you:

    -----

    <html>
    <head>

    <link href="http://wforms.googlecode.com/svn-history/r280/trunk/css/wforms-jsonly.css" type="text/css" rel="stylesheet" />
    <link href="http://wforms.googlecode.com/svn-history/r280/trunk/css/wforms-layout.css" type="text/css" rel="stylesheet" />
    <script type="text/javascript" src="http://wforms.googlecode.com/svn-history/r280/trunk/lib/base2/beta2/base2-p.js"></script>
    <script type="text/javascript" src="http://wforms.googlecode.com/svn-history/r280/trunk/lib/base2/beta2/base2-dom-p.js"></script>
    <script type="text/javascript" src="http://wforms.googlecode.com/svn-history/r280/trunk/wforms_core.js"></script>
    <script type="text/javascript" src="http://wforms.googlecode.com/svn-history/r280/trunk/wforms_switch.js"></script>

    <style type="text/css">
    .onstate-phone { display: block; }
    .offstate-phone { display: none; }
    </style>
    </head>
    <body>

    <form name="userinfo" action="insert.php" method="post">

    How would you like us to contact you?<br>
    <input type="checkbox" name="ContactPreference" value="email" class="switch-phone" />Email
    <div class="offstate-phone">
    What time of the day would you prefer to be contacted by phone?
    <select name="TimeOfDay">
    <option value="Morning">Morning</option>
    <option value="Noon">Noon</option>
    <option value="Afternoon">Afternoon</option>
    <option value="Evening">Evening</option>
    </select>
    </div>
    <input type="Submit">
    </form>

    </body>
    </html>

    ---------

    Happy to help further,
    FormAssembly.com Support.