Solved

reset form fields to nothing

Posted on 2007-03-26
4
210 Views
Last Modified: 2010-04-16
hi everyone,
using the form reset button it only resets to the values that the page loads with..

Is it possible to clear all values within the form, even though its prepopulated with session data.

i.e. set all text fields to '' and set all radios to empty?  
thanks
0
Comment
Question by:jimbona27
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 10

Accepted Solution

by:
Jaax earned 50 total points
ID: 18792385
There is no predefined function supplied by javascript to clear all the values.
You have to do it explicitly; something like this inside the script:
for(i=0;i<document.forms[0].elements.length; i++){
  ele = document.forms[0].elements[i];
  if(ele.type == "text" || (ele.type == "textarea" ){
     ele.value == "";
 }else if(ele.type == "radio") {
     if(ele.length){
         for(j=0; j<ele.length;j++){
             ele[j].checked = false;
         }
     }else{
       ele.checked = false;
     }
     //Continue checking for all the other element types like check box, hidden etc
 }
 

}
0
 

Author Comment

by:jimbona27
ID: 18816066
just checking it out, got a few problems with the code so just debugging it. let you know.
0

Featured Post

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

732 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