User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 391,663 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,871 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 611 | Replies: 2
Reply
Join Date: Oct 2007
Posts: 2
Reputation: chronoel is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
chronoel chronoel is offline Offline
Newbie Poster

Can I specify only some form elements to reset?

  #1  
May 20th, 2008
I have a form with a reset button and what I want is to reset only some form elements when that button is clicked.
<form name="frmMyForm">
<input type="text" name="txtText" />
<input type="checkbox" name="chkCheckBox" />

<input type="reset" value="reset" />
</form>
Now I want the checkbox to be reset when I click the reset button is clicked and let the textbox retain its value
Is it possible?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: May 2008
Location: Nant-y-moel, South Wales
Posts: 9
Reputation: ajberrow is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
ajberrow's Avatar
ajberrow ajberrow is offline Offline
Newbie Poster

Re: Can I specify only some form elements to reset?

  #2  
May 20th, 2008
I don't know if this is the BEST way to do it, but this would work :

    <head>
    
        <script language="javascript">
        function fnMyReset() {
            document.frmMyForm.chkCheckBox.checked = false;
        }
        </script>
    
    </head>
    
    <body>
    
        <form name="frmMyForm">
        
            <input type="text" name="txtText" />
            <input type="checkbox" name="chkCheckBox" />
            
            <!-- changed from type="reset" to type="button" -->
            <input type="button" value="reset" onclick="fnMyReset()" />
        
        </form>
    
    </body>
Reply With Quote  
Join Date: Jan 2007
Posts: 2,510
Reputation: MidiMagic is on a distinguished road 
Rep Power: 7
Solved Threads: 103
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Posting Maven

Re: Can I specify only some form elements to reset?

  #3  
May 20th, 2008
Use a regular button with the word RESET on the face. Use it to call a function to put default values in the ones you want to reset. I wrote several of these.
Daylight-saving time uses more gasoline
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb JavaScript / DHTML / AJAX Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 1:49 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC