Inserting variable into hidden input

N

Navillus

Hi all,

I'm trying to insert a javascript variable into a hidden input form
field. Here's what it looks like:

<form name="loginForm"
action="scripts/wgate/ziac_login/!?~language=EN">
<input type="hidden" name="pss" value="`G_NEW_PASSWORD.value`">
<input type="hidden" name="usr" value="">
<input type="submit" value="Please Click Here to Continue">
</form>

and then later down the page I try to reassign "usr" like this:

<script>
var allcookies = document.cookie;
var position = allcookies.indexOf("user=");
var start = position + 5;
var end = allcookies.indexOf(";", start);
if (end == -1) end = allcookies.length;
var valueofuser = allcookies.substring(start, end);
valueofuser = unescape (valueofuser);
document.write(valueofuser);
document.loginForm.usr.value = valueofuser;
</script>

I can see it is printing out document.write(valueofuser) correctly, so
I know it is grabbing the user name. But it doesn't seem to want to
insert it into the form on the next line. Any suggestions?
 
N

Navillus

Navillus said:
Hi all,

I'm trying to insert a javascript variable into a hidden input form
field. Here's what it looks like:

<form name="loginForm"
action="scripts/wgate/ziac_login/!?~language=EN">
<input type="hidden" name="pss" value="`G_NEW_PASSWORD.value`">
<input type="hidden" name="usr" value="">
<input type="submit" value="Please Click Here to Continue">
</form>

and then later down the page I try to reassign "usr" like this:

<script>
var allcookies = document.cookie;
var position = allcookies.indexOf("user=");
var start = position + 5;
var end = allcookies.indexOf(";", start);
if (end == -1) end = allcookies.length;
var valueofuser = allcookies.substring(start, end);
valueofuser = unescape (valueofuser);
document.write(valueofuser);
document.loginForm.usr.value = valueofuser;
</script>

I can see it is printing out document.write(valueofuser) correctly, so
I know it is grabbing the user name. But it doesn't seem to want to
insert it into the form on the next line. Any suggestions?

anyone?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top