Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2004
    Posts
    202

    Unanswered: Reseting the page which has 2 forms

    Hi there,

    I have a problem here which i cant seem to think how to overcome.
    I need to reset the page which contains a few textboxes in one form and a few other textboxes in another form.
    My reset button is in the form below.
    So if i click the reset button, only the bottom form textboxes and radio combo boxes will be reset and not in the other form.
    How to reset all the textboxes and the one whole page which contain 2 forms?
    thanx

  2. #2
    Join Date
    Dec 2003
    Posts
    148
    Example:
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <script>
    function Reset()
    {
     document.FormName.TextBox1.value = '';
     document.OtherFormName.TextBox2.value ='';
    }
    </script>		
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    
    <body>
    <form name="FormName">
    <input type="text" name="TextBox1">
    </form>
    
    <form name="OtherFormName">
    <input type="text" name="TextBox2">
    <input type="button" onClick="Reset();" value="Reset">
    </form>
    
    
    </body>
    </html>
    Write a simple javascript function that fire onClickof your button and clears all the textboxes you want.

  3. #3
    Join Date
    Jul 2003
    Location
    SoCal
    Posts
    721
    There is a JavaScript "reset()" function on the form that you can call from the function instead of having to hit every field manually...

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <script>
    function Reset()
    {
     document.FormName.reset();
     document.OtherFormName.reset();
    }
    </script>		
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    
    <body>
    <form name="FormName">
    <input type="text" name="TextBox1">
    </form>
    
    <form name="OtherFormName">
    <input type="text" name="TextBox2">
    <input type="button" onClick="Reset();" value="Reset">
    </form>
    
    
    </body>
    </html>
    That which does not kill me postpones the inevitable.

  4. #4
    Join Date
    Dec 2003
    Posts
    148
    nice, i was unaware of that :-)

  5. #5
    Join Date
    Jul 2003
    Location
    SoCal
    Posts
    721
    ya learn something new every day...
    That which does not kill me postpones the inevitable.

  6. #6
    Join Date
    Dec 2004
    Posts
    7

    Talking Hey try this

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <script>
    function Reset()
    {
    for (var loop=0; loop<document.forms.length; loop++)
    {
    document.form[loop].reset();
    }
    }
    </script>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body>
    <form name="FormName">
    <input type="text" name="TextBox1">
    </form>

    <form name="OtherFormName">
    <input type="text" name="TextBox2">
    <input type="button" onClick="Reset();" value="Reset">
    </form>


    </body>
    </html>

  7. #7
    Join Date
    Dec 2003
    Posts
    148
    michaelfg81, I should hope one of the many solutions we've provided have worked for you?

Posting Permissions

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