specify elements of a form to clear using reset button

Posted on 2007-07-25
Last Modified: 2010-04-09
Is there a way to specify what elements of a form are cleared when using a standard reset button?  Can you specify by name what textboxes for example are cleared and the ones not specified will remain intact?
Question by:dale4brumbaugh
    LVL 3

    Expert Comment

    Not without javascript.  You can either blank out everything or reset everything to default states.
    LVL 25

    Accepted Solution

    put this in between the <head> tags, and make sure you modify it to your actual form name (if your form doesn't have one put it in), and the name of your form fields
    <script language="Javascript">
    function clearFields()
      document.TheNameOfYourForm.TheNameOfYourField.value = "";

    then just copy/paste:   document.TheNameOfYourForm.TheNameOfYourField.value = "";

    for each field you need cleared...making sure to change the names....

    then at you submit button, put:
    <input type="button" onclick="javascript:clearFields();" value="Clear" name="btnClear">

    Author Comment

    exactly what i was looking for.  thank you
    LVL 25

    Expert Comment

    any time

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
    This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
    The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
    The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now