• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

problem with jsp for reset() method

 
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

im facing problem with reset() function


Which problem ? Can you explain your problem clearly ?
 
madhuri kunchala
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if i want to clear my form..it is not get cleared..'clear' button is not working...i had posted my jsp page...can you once check it..and provide me where i went wrong..
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the "reset" input does not clear text fields. It resets them to their original value.
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By the way, this looks like the same question as the other one you asked here https://coderanch.com/t/504642/HTML-JavaScript/reset-function
 
madhuri kunchala
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes..it is related to jsp..so i posted in jsp forum..it contains javascript also..
 
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
//way 1 if your button type is reset
[code]
<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>

[code]

 
madhuri kunchala
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i tried what you had given in Way2...it is not working....i got why it is not working...i had doubt that i had text fields,combo boxes, check boxes and textarea in my form..for clear of form in javascript for clear..i need to mention all id's or just simple the form name is enough...i tried using form id for clear of my form fields...here is the code..



<input type="reset" value="clear" onClick="clearFields()">

can you check it once...
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This wont work, because value is applicable to a component like text field, password field etc, not to the form.
 
madhuri kunchala
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
kk..i changed it to



eventhough it is not working...can you tell me inorder to clear the form which had default values is not possible am i right..
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


The above will again trigger the default reset event, and only reset the fields not clear. Clearing form is possible, didn't you try this?

 
madhuri kunchala
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i tried its working....can i implement in my forum..what is "a" in this--- ' onClick="return a=clearFields()" '
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The default behavior of submit button is to submit the form data, and reset button is to reset the form data so implicitly it calls document.form.reset(). Now to change it's behavior you need to pass a false value to it. So as per the code, clearForm method returns a false value which is assigned to variable a, which is further passed to the reset method.
 
madhuri kunchala
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
k...thanks for you help..i had another problem..in my form..i'll post it as another question...can you check it and provide me what to do...
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just for a note, if you wish to clear multiple fields you can have a look on the following code snippet



I didn't exactly understand what exactly you mean by

in my form..i'll post it as another question.

 
madhuri kunchala
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks..i'll try it ....not that what you are understanding...for check boxes im asking...i posted my problem..
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
check box solution is already given in the code, give it a look.
 
madhuri kunchala
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
k..i'll try it and let me know the process
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Swastik Dey wrote:The default behavior of submit button is to submit the form data, and reset button is to reset the form data so implicitly it calls document.form.reset(). Now to change it's behavior you need to pass a false value to it. So as per the code, clearForm method returns a false value which is assigned to variable a, which is further passed to the reset method.


But if you're not using the return value from the reset function there's no reason to assign it to a value--just return the results of the function execution. Otherwise it's just unnecessary clutter.
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the clarification.
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

madhuri kunchala wrote:yes..it is related to jsp..so i posted in jsp forum..it contains javascript also..


It is not related to JSP. This question has nothing at all to do with JSP. This is purely an HTML and JavaScript issue.
 
madhuri kunchala
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
thanks to Swastik Dey ...what he suggested i implemented its working fine...thanks for this forum...
 
WARNING! Do not activate jet boots indoors or you will see a tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic