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 3 of 3
  1. #1
    New Coder
    Join Date
    Nov 2004
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    CCS hide and show not working in form

    Hi

    I am making a form that is dynamic. When a user selects a question another part is displayed. This all works fine without the first form tag in place. As soon as put the first form tag in place I get an error on javascript and it says it can't find a function. I have made the code below so you can see it. Please keep in mind its not finished and only one of the buttons leads to another part being displayed. In the current form the script will not work, however you will see I have marked the line to take out and then the script will work. Of course it is no good me leaving this line out as it needs to be there to make sure the form works. Any ideas where im going wrong.

    <html>
    <head>
    <title></title>
    <style type="text/css">
    <!--
    .blockDisplayOff {
    display: none;
    }
    .blockDisplayOn {
    display: block;
    }
    -->
    </style>
    <script language="JavaScript">
    <!--
    function show(DOM_Item)
    {
    if (document.getElementById) // netscape 6+ IE 5+ - make IE 4 compatible
    {
    thisItem = document.getElementById(DOM_Item).style;
    thisItem.display = "block";
    }
    }
    function hide(DOM_Item)
    {
    if (document.getElementById)
    {
    thisItem = document.getElementById(DOM_Item).style;
    thisItem.display = "none";
    }
    }
    function advertType(display) {
    if (display) show('showAdvertSell');
    else hide('showAdvertSell');
    }
    function freightType(display) {
    if (display) show('showFOB');
    else hide('showFOB');
    }
    function locationType(display) {
    if (display) show('showCountrySelect');
    else hide('showCountrySelect');
    }
    //-->
    </script>
    </head>
    <body onLoad="advertType(1);freightType(0);">

    <?php
    echo '
    //remove the line below this and it will work
    <form action="'.$reg_page.'" name="formMemberRegistration" id="formMemberRegistration" method="post" onSubmit="return validateMemberRegistration()">
    //remove the line above this and it will work

    <table width="770" align="center" cellspacing="0" cellpadding="0" border="0">
    <tr>
    <td>Advert Name/td>
    <td><input type</td>
    </tr>
    <tr>
    <td colspan="2">&nbsp;</td>
    </tr>
    <tr>
    <td colspan="2">What type of advert do you want to place?</td>
    </tr>
    <tr>
    <td colspan="2">&nbsp;</td>
    </tr>
    <tr>
    <td colspan="2"><input type="radio" name="advertType" value="1" checked onClick="advertType(1);">Place an advert for *** for sale&nbsp;&nbsp;</td>
    </tr>
    <tr>
    <td colspan="2"><input type="radio" name="advertType" value="0" onClick="advertType(0);">Place a wanted advert for ****.'.'</td>
    </tr>
    </table>
    <span class="blockDisplayOff" id="showAdvertSell">
    <br>
    <table width="770" align="center" cellspacing="0" cellpadding="0" border="0">
    <tr>
    <td colspan="2"><br>Please select where the goods are located. You can either have ex-works so that companies will collect the goods from your factory or select FOB so that you will deliver to a sea port at the border. If in doubt leave it set to ex-works.</td>
    </tr>
    <tr>
    <td colspan="2">&nbsp;</td>
    </tr>
    <tr>
    <td colspan="2"><input type="radio" name="freightType" value="0" checked onClick="freightType(0);">Ex-Works&nbsp;&nbsp;</td>
    </tr>
    <tr>
    <td colspan="2"><input type="radio" name="freightType" value="1" onClick="freightType(1);">F.O.B.</td>
    </tr>
    </table>
    </span>
    <span class="blockDisplayOff" id="showFOB">
    <br>
    <table width="770" align="center" cellspacing="0" cellpadding="0" border="0">
    <tr>
    <td colspan="2">Are the goods located in the country you are located in (the country you registered)</td>
    </tr>
    <tr>
    <td colspan="2">&nbsp;</td>
    </tr>
    <tr>
    <td colspan="2"><input type="radio" name="locationType" value="1" checked onClick="locationType(0);">Yes&nbsp;&nbsp;</td>
    </tr>
    <tr>
    <td colspan="2"><input type="radio" name="locationType" value="0" onClick="locationType(1);">No</td>
    </tr>
    </table>
    </span>
    <span class="blockDisplayOff" id="showCountrySelect">
    <br>
    <table width="770" align="center" cellspacing="0" cellpadding="0" border="0">
    <tr>
    <td colspan="2">Please select the country that the goods are located from the drop down list.</td>
    </tr>
    <tr>
    <td colspan="2">&nbsp;</td>
    </tr>
    <tr>
    <td colspan="2">Country select goes here</td>
    </tr>
    </table>
    </span>

    <table width="770" align="center" cellspacing="0" cellpadding="0" border="0">
    <tr>
    <td colspan="2" align="right"><input type="submit" name="Submit" value="Next &gt;"></td>
    </form>
    ';

    ?>


    </body>
    </html>

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,519
    Thanks
    3
    Thanked 507 Times in 494 Posts
    function names and element names MUT NOT be the same
    Code:
    <td colspan="2"><input type="radio" name="freightType" value="0" checked onClick="freightType(0);">Ex-Works&nbsp;&nbsp;</td>
    
    function freightType(display) {
    if (display) show('showFOB');
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/

  • #3
    New Coder
    Join Date
    Nov 2004
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Cool, thanks mate brilliant it now works. I must of being thick when I did that but managed to miss it. You have saved me alot of time and stress.

    Steve


  •  

    Posting Permissions

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