Hello Everyone,
I am trying to set the value of a Input tag with a value retrieved from the cookies. However, it is not working. Here is the script:
[CODE]<html>
<head>
<title>Example</title>
</head>
<body>
<script type=”text/javascript”>
document.cookie = “username=John”;
var user = get_cookie(“username”);
document.write ( “Hi ” + user + “, welcome to my website!” );
oFormObject.elements[“name”].value = user;
</script>
<center> <br><br><br><br>
<form name=”register_complaint” action=”#”>
User Name: <input type=”text” size=”5″ name=”name” > <br>
<input type=”checkbox” name=”remeber”>Remember Me <br>
<input type=”button” name=”submit” value=”Submit Complaint”>
</form>
</center>
<script type=”text/javascript”>
function get_cookie ( cookie_name )
{
var results = document.cookie.match ( ‘(^|;) ?’ + cookie_name + ‘=([^;]*)(;|$)’ );
if ( results )
return ( unescape ( results[2] ) );
else
return “”;
}
</script>
</body>
</html>
Please help me, I’ve been struggling with this issue for a long time.
Cheers