my dog learned polymorphism*
The moose likes HTML, CSS and JavaScript and the fly likes problem in reset() function Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply locked New topic
Author

problem in reset() function

madhuri kunchala
Ranch Hand

Joined: Mar 30, 2010
Posts: 350
hi,
in my application...i had a modify page...im facing problem with reset() function...here is my code...can anyone provide me the solution



clear.js

Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1449
    
    6

As far as I know reset does not clear the text fields, rather it populates the text fields with initial values.


Swastik
madhuri kunchala
Ranch Hand

Joined: Mar 30, 2010
Posts: 350
it will clear all the fields...by using 'reset' command
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1449
    
    6

Will it? Let's try this



I have a default value as hello in the text field. If I click reset nothing happens. Now lets change the value in the text field say hi, and click reset, now we get the text field displaying hello.
madhuri kunchala
Ranch Hand

Joined: Mar 30, 2010
Posts: 350
the problem is the default value. if default values is not given it'll work. the code is

Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1449
    
    6

That is what I was trying to say,
As far as I know reset does not clear the text fields, rather it populates the text fields with initial values.
it will reset the text fields with initial contents. So if your value is blank you get blank or else you get the default value.
madhuri kunchala
Ranch Hand

Joined: Mar 30, 2010
Posts: 350
ok..i got your point..i had doubt that in my modify page im getting the values from already existing one...so im unable to reset the fields..is there anyother way to do that...i had posted my code in forum...can you once check it...and tell me is there anyother solution
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1449
    
    6

//way 1 if your button type is reset

<Script>
function clearFields(){
document.getElementById("t1").value="";
return false;
}
</Script>
<form>
<input type=text id="t1" value=Hello><br>
<input type=reset onClick="return a=clearFields()">
</form>


//way 2 if your button type is simple button

<Script>
function clearFields(){
document.getElementById("t1").value="";
}
</Script>
<form>
<input type=text id="t1" value=Hello><br>
<input type=button value="reset" onClick="clearFields()">
</form>
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Do not cross post.

http://www.coderanch.com/t/504657/HTML-JavaScript/jsp-reset-method

closing this

Eric
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem in reset() function
 
Similar Threads
problem with jsp for reset() method
Check a checkbox after hitting a reset button
html:multibox problem
How to reset s:select
Can't reset DOJO DateTextBox