Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Inserting variable into hidden input

Reply
Thread Tools

Inserting variable into hidden input

 
 
Navillus
Guest
Posts: n/a
 
      03-06-2006
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?

 
Reply With Quote
 
 
 
 
Navillus
Guest
Posts: n/a
 
      03-07-2006

Navillus wrote:
> 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?

 
Reply With Quote
 
 
 
 
Jonas Raoni
Guest
Posts: n/a
 
      03-07-2006
Navillus wrote:
> Navillus wrote:
>>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?


I don't know what to say, this sentence is quite simple, there's nothing
to find on it =]


--
Jonas Raoni Soares Silva
http://www.jsfromhell.com
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using a variable for a hidden input value Kim HTML 5 08-04-2009 05:11 PM
can i pass data with input text instead of input hidden? Walter ASP General 6 09-17-2004 11:16 AM
Inserting Input data into a HTTP post. Geoff XML 3 06-10-2004 05:23 PM
inserting Checkboxlist input into database wjer ASP .Net 1 03-02-2004 06:26 AM
Inserting into one table data from 2 tables and some input data. Renie83 ASP General 1 07-10-2003 08:29 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57