Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old October 6th, 2005, 02:00 PM
Authorized User
 
Join Date: Aug 2005
Location: , , .
Posts: 64
Thanks: 0
Thanked 0 Times in 0 Posts
Default how 2 reset a form

hi again
how 2 reset a form without inserting RESET button
i mean 2 create a function ... whenever it iz called ... it should reset the form in the document
i m w8ing 4 a good reply
bye bye

  #2 (permalink)  
Old October 6th, 2005, 02:11 PM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

How about writing clear, coherent sentences in *valid* English?

No? Asking too much? ;)

Well you might do something like this:
Code:
<form id='some-form' method='post' action='whatever.page'>


</form>
Then use a JavaScript function to reset the form
Code:
<script type='text/javascript'>
     function resetForm()
     {
         document.getElementById('some-form').reset();
     }
</script>
Then choose how you want to reset the form. This is a matter of selecting the right event.. here's an example of clicking a link to reset the form.
Code:
    <a href='javascript:void(0);' onclick='resetForm();'>Reset Form</a>
HTH!

Regards,
Rich

--
[http://www.smilingsouls.net]
Mail_IMAP: A PHP/C-Client/PEAR solution for webmail
Author: Beginning CSS: Cascading Style Sheets For Web Design
  #3 (permalink)  
Old October 6th, 2005, 02:21 PM
Authorized User
 
Join Date: Aug 2005
Location: , , .
Posts: 64
Thanks: 0
Thanked 0 Times in 0 Posts
Default

sorry but ... actually i couldnt understand
i mean iz it necessary 2 create an ID for the from (actually i dont know how 2 create ID) ... so iznt there n.e simple method :-( ???

  #4 (permalink)  
Old October 6th, 2005, 04:07 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: High Wycombe, UK, United Kingdom.
Posts: 344
Thanks: 0
Thanked 1 Time in 1 Post
Default

if the form has a NAME property then you could do :

document.<form name>.reset();

or

document.forms['<form name>'].reset();

if it is the third form on the page you could even do :

document.forms[3].reset();
  #5 (permalink)  
Old October 8th, 2005, 01:56 PM
Authorized User
 
Join Date: Aug 2005
Location: , , .
Posts: 64
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by Greg Griffiths
 if the form has a NAME property then you could do :

document.<form name>.reset();

or

document.forms['<form name>'].reset();

if it is the third form on the page you could even do :

document.forms[3].reset();
:( it didNt work :(

  #6 (permalink)  
Old October 9th, 2005, 01:43 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: High Wycombe, UK, United Kingdom.
Posts: 344
Thanks: 0
Thanked 1 Time in 1 Post
Default

can you post your Code and your HTML ?
  #7 (permalink)  
Old October 10th, 2005, 05:45 AM
Authorized User
 
Join Date: Aug 2005
Location: , , .
Posts: 64
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by Greg Griffiths
 can you post your Code and your HTML ?
Thanksssss alotttt my friend:)
it'z working ... actually i was making a small mistake there4 it wazn't working but now it'z working perfectly
thanks



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to reset the form? vinaykurudi Apache Tomcat 0 September 29th, 2008 05:26 AM
Notice: Undefined variable: comments/ Form reset dungey Pro PHP 10 December 1st, 2006 04:00 AM
Controlling reset method of form bean chamalsl Struts 2 August 8th, 2006 12:06 AM
BackgroundImage reset ryan.thomson VB.NET 2002/2003 Basics 0 October 25th, 2005 08:39 AM
C# reset of checkbox after form submission booksnore2 General .NET 5 July 29th, 2004 10:30 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.