471,854 Members | 1,917 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,854 software developers and data experts.

how to keep created elements in javascript on reload

samikhan83
hi All Experts.... once again i am in some problem.......

i have a form which creates a new textbox elements when a new product is scanned with barcode scanner.

Problem is when i submit the form and check for server side validation if the form have some error according to validation it is going to the form again and all the generated textbox vanishes ... and i am loosing all the entered data and fields.

There is any way to keep the generated element intact with there respective data .

so please can anybody help me with this .

Waiting For Your Reply
Aug 25 '08 #1
4 1834
Dormilich
8,658 Expert Mod 8TB
as I understand it right, the barcode scanner fires a javascript event that creates the textbox, right?
in that case, the returning form (from the failed validation) misses that event and the standard form is returned. you can only prevent that by explicitly writing a new textbox through the server side script with the data as default value (and of course interrupting the barcode event as long as the validation process is not finished).

hope that helps a bit
Aug 25 '08 #2
Thanks For Your Reply....

i to thought of doing that ...... but is there anyway of caching the element and the values and reusing it .....

instead of regenerating all the elements again.... because it very complex form...

where form is for Purchase Invoice Entry of inventory system where user will scan product after product like multiple product with there serial number so
for each product upc code new elements with zero value price,quantity and serial number will be generate and each product have multiple serial number.....

so the form grow dynamically by getting the values from database with AJAX....

if there is any solution then highly APPRECIATED....
Aug 25 '08 #3
Dormilich
8,658 Expert Mod 8TB
i to thought of doing that ...... but is there anyway of caching the element and the values and reusing it .....
you might try to send the form element collection back as an AJAX request (I think you have to serialize, WDDX is worth looking at).
Expand|Select|Wrap|Line Numbers
  1. // general idea:
  2. var form = serialize(document.forms[0]);
  3. ...
  4. XMLhttpRequest.send(form);
Aug 25 '08 #4
yaah i will give it a try... i think it should work

thanx for your suggestion....
Aug 26 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Will | last post: by
reply views Thread by YellowAndGreen | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.