Solved

reset form fields to nothing

Posted on 2007-03-26
4
212 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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
The viewer will learn how to count occurrences of each item in an array.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

705 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