469,622 Members | 2,155 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,622 developers. It's quick & easy.

Javascript Keep data form after reload


I tried an script for keep my data form after reload page, but I've some errors.
In this momento I runnung my own browser because we've an intranet. And for security reason, our page reload every 10 minutes for keep my login live.
But, we've some forms, and 10 minutes is a shorcut time to do that, and very 10 minutos, our page reload, and we lose all data in form (before submit).
So, for that reason , I want to keep my data after reload, but clear after submit.

My problem right now is, I've a javascript, keep my data, BUT every time I access to that page appear an syntax error.


<SCRIPT Language="JavaScript">

var url_str = window.location.toString();
var url_split = url_str.split('?');

var var_split = url_split[1].split('&');
x = 0;
i = 0;
while (i < var_split.length)
curr_val = var_split[i].split('=');
document.form1[x].value = curr_val[1];
x = x+1;
i = i+1;



<FORM Name="form1" Method="get" Action="example.html">
<INPUT Type="text" Name="1">
<INPUT Type="text" Name="2">
<INPUT Type="submit" Value="Post">
Once you have completed the form to save click post then bookmark this page.


The error appear in
Line: 11
char: 1
error: syntax error
code: 0

Somebody knows what happen with this script?

Thank you for your help
Nov 14 '06 #1
3 8998
4,258 Expert 4TB
Do you want me to guess what it could be?? What is line 11?

Ronald :cool:
Nov 14 '06 #2
Do you want me to guess what it could be?? What is line 11?

Ronald :cool:
hahahaha. Im sorry Ronald. Is my fault!

the line 11 is the else.

var var_split = url_split[1].split('&');

That "else" show me error in explorer and I dont know why.
I really appreciate your help.
Thank you
Nov 14 '06 #3
392 Expert 256MB
Is there more to the script than is shown? The else needs to have an If before it, and I see two opening braces, but three closing ones.

Assuming that there is an if statement that is just now shown, and assuming that there is only one "?" to split on then the array pointer should be 0 not 1. The first value in arrays is zero.
Nov 14 '06 #4

Post your reply

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

By using this site, you agree to our Privacy Policy and Terms of Use.