Clear form button to call java onclick function...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • plumba
    New Member
    • Aug 2007
    • 57

    Clear form button to call java onclick function...

    Ok, another query....

    I have a checkbox at the bottom of my form which when checked unhides a <div> block which displays the submit button.

    The problem I have is when the clear form button is pressed it removes the check but does not re-hide the submit <div> bit.

    The way i see it, I have 3 options:
    1) To simply remove the clear for button.
    2) To exclude the said checkbox from the CLEAR button function.
    3) To have the CLEAR button run an onlick to call the function which hides the submit button.

    The latter would be my prefered. It sort of works in that the first click of the clear button clears the form, the second click calls the javascript which hides the <div> section.

    This is the function which toggles the display:
    [CODE=javascript]<script>
    function toggle_display( ) {
    var form = document.getEle mentById('hides ubmit');
    var submit = document.getEle mentById('submi t_group');
    ((form.checked) ? submit.style.di splay='block': submit.style.di splay='none');
    }
    </script>[/CODE]

    This is the lower part of the form which has the clear button in....

    [HTML]<div id="submit_grou p" style="display: none;">
    <table border="0" width="70%" id="table22" bgcolor="#CCFFF F">
    <tr>
    <td>
    <p align="center"> <font size="2">You may now click the SUBMIT button to
    submit your e-Enrolment.</font><p align="center"> <font size="2">When you click SUBMIT a screen will pop up indicating a program is sending an Email on your behalf.<br>
    <b>You must click YES to submit the form.</b></font></td>
    </tr>
    </table>
    <p>


    <input type="Submit" value="Submit!" >

    </p>
    </div>


    <textarea rows="7" name="Authority " cols="30" style="width:75 3; font-weight:bold; height:116; font-family:Arial" wrap=virtual>AC CESS AUTHORISATION
    I will tick the box to agree.....
    </textarea><br>
    <input type="checkbox" name="agreechec k" id="hidesubmit " value="Agreed" onClick="toggle _display();"/>
    By placing a check in the box you are agreeing to the above Access Authorisation Statement.</font></b></p>
    <input type="reset" onClick="toggle _display();" value="Clear Form"/>
    <input type="hidden" name="EOR" value="">
    </form>[/HTML]

    Can I throw this open to suggests/comments...

    Regards
    Last edited by pbmods; Sep 4 '07, 03:21 PM. Reason: Changed [CODE] to [CODE=javascript].
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Moved from Articles to forum section where the question is more likely to be answered.

    Comment

    • plumba
      New Member
      • Aug 2007
      • 57

      #3
      Originally posted by acoder
      Moved from Articles to forum section where the question is more likely to be answered.
      Thanks acoder - I always make that mistake!!

      Comment

      • epots9
        Recognized Expert Top Contributor
        • May 2007
        • 1352

        #4
        does it work or does it give you an error message?

        Comment

        • plumba
          New Member
          • Aug 2007
          • 57

          #5
          Originally posted by epots9
          does it work or does it give you an error message?
          No I get no error messages, it just makes me click it twice....

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            I think I know what is happening. You are using a reset button which is running the toggling code and then resetting the checkbox so the div is not hidden. One possible solution is to call reset() first.

            Comment

            Working...