aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes retaining value in java script Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "retaining value in java script" Watch "retaining value in java script" New topic
Author

retaining value in java script

Maan Suraj
Ranch Hand

Joined: Dec 20, 2007
Posts: 299
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?


Man Suraj
Someone says "Impossible is nothing". The man next him says "Let me see you licking your elbow tip!"
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61772
    
  67

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Maan Suraj
Ranch Hand

Joined: Dec 20, 2007
Posts: 299
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

Joined: Jan 10, 2002
Posts: 61772
    
  67

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

Joined: Jan 15, 2008
Posts: 10
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

Joined: Jan 10, 2002
Posts: 61772
    
  67

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: retaining value in java script