The script i'm trying to write consist of asking the user for his name in a form format which is then sent in a cookie. When the user reconnect to the same page, it displays : Hi, "HISNAME", welcome to my site! I don't know what I'm doing wrong, seriously.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
<script type="text/javascript">
if ( ! get_cookie ( "username" ) )
{
var username = document.write(
Everything in document.write needs to be in between the ( and ) on one line, and needs to be surrounded by " and ", which things like name="name" would break.
You could set a var thisContent = ""; then use the shortcut for appending the data and split it up across several lines, then document.write(thisContent);
Code:
var thisContent = "";
thisContent += "blah blah blah blah";
thisContent += "bleh bleh bleh bleh";
// and escape the "
thisContent += "<input name=\"name\" />";
document.write(thisContent);
Bookmarks