Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

retaining value in java script

 
Maan Suraj
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suppose i have 3 text fields. The user enters the values for all the fields and clicks submits. Now if third text field gives some error....I want to retain the values of first 2 text boxes and set focus on 3rd text box where the error occured.How can i do this?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64970
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using any server-side templating technology such as JSP or PHP? If so, simply use that to set the value attributes of the fields to their submitted values.
 
Maan Suraj
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no i am not using any servlet technology. i just have an html page.....

can you please explain this through a small example
thanks in advance
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64970
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's little in native HTML and JavaScript to help you with this. The easiest way to do this is on the server side. How are you processing your form data on the server -- you have to be using something.

You might also look into something like Google Gears, but if you can already do it on the server, that'd be easiest.
 
Sapika Am
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
u could do a javascript validate routine linked to onSubmit, Before form gets submitted. and bring focus to the offending element
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64970
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sapika Am:
u could do a javascript validate routine linked to onSubmit, Before form gets submitted. and bring focus to the offending element

What does this have to do with the question?

Moreover, please use real words when posting to the forums. Abbreviations such as "u" in place of "you" only serve to make your posts more difficult to read and less likely to generate useful responses.

Please read this for more information.

thanks,
bear
JavaRanch sheriff
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic