passing Javascript var to PHP

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
PingLeeQuan
Forum Commoner
Posts: 58
Joined: Tue Sep 03, 2002 8:08 am

passing Javascript var to PHP

Post by PingLeeQuan »

in java script, i am getting the cookie that was deposited by another script. If i find the cookie, i parse it to extract the "Access Level" from it. I am having difficulties in passing this value (Access Level) to the next PHP page even when i do the following:

tempvar="<input type=hidden name=mode value=" + AccessLevel + ">";
document.write(tempvar);

When i go to the next php page and try to access the variable mode, I get an error.

Thanks
quan
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Are you putting that hidden field within a larger form or even just between <form> tags?

Mac
PingLeeQuan
Forum Commoner
Posts: 58
Joined: Tue Sep 03, 2002 8:08 am

Post by PingLeeQuan »

thanks for your response.

yes.. and i am using document.location.href = 'AuthLogin.php'; after the fact that i am setting the AccessLevel
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

What's the error you receive when you try and access the information?

Mac
PingLeeQuan
Forum Commoner
Posts: 58
Joined: Tue Sep 03, 2002 8:08 am

Post by PingLeeQuan »

twigletmac thanks again... I found the problem, the problem was it gave me the string name "AccessLevel" instead of the value. i was not escaping the appropriate quotes.

thanks a bunch
--quan :roll:
Post Reply