Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

reset form fields to nothing

Posted on 2007-03-26
4
Medium Priority
?
221 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 200 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
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…
Suggested Courses

609 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