slephnir
05-21-2004, 08:33 AM
Hi,
I am writing a simple JavaScript to take a string and match it, when a matching string is received the browser is supposed open a new page called newpage.html.
At the moment the browser executes the code without syntax errors but it will not bring up the new page "newpage.html" as it is supposed to.
If anyone can have a look at this code and tell me what I am doing wrong, it would be very helpful.
<html>
<head>
<title>document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<SCRIPT LANGUAGE="JAVASCRIPT">
function search(){
var search = a;
search = document.search.textfield;
if (search == 'a') { location = "newpage.html" }
}
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<form name=search method=POST onSubmit="return validate(search)";>
<P>Please enter a search keyword</p>
<input type="text" name="textfield">
<input type="submit" name="Submit" value="Submit" onClick=" search()">
</form>
</body>
</html>
:confused:
I am writing a simple JavaScript to take a string and match it, when a matching string is received the browser is supposed open a new page called newpage.html.
At the moment the browser executes the code without syntax errors but it will not bring up the new page "newpage.html" as it is supposed to.
If anyone can have a look at this code and tell me what I am doing wrong, it would be very helpful.
<html>
<head>
<title>document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<SCRIPT LANGUAGE="JAVASCRIPT">
function search(){
var search = a;
search = document.search.textfield;
if (search == 'a') { location = "newpage.html" }
}
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<form name=search method=POST onSubmit="return validate(search)";>
<P>Please enter a search keyword</p>
<input type="text" name="textfield">
<input type="submit" name="Submit" value="Submit" onClick=" search()">
</form>
</body>
</html>
:confused: