This thread is pretty ancient. Here's how I'd write it now:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>A title</title>
</head>
<body>
<form action="jumpurl.cgi" onsubmit="
var e = this.elements,
u = e.urlstring.value,
d = e.urldom.value;
return !!(u && d
&& (u.defaultValue !== u.value)
&& (this.action = u + d));
">
<p>
<input type="text" name="urlstring" value="http://..." style="
color: silver;
background-color: white;
"
onfocus="
this.value === this.defaultValue && (this.value = '');
this.style.color = 'black';
"
onblur="
if(!this.value) {
this.value = this.defaultValue;
this.style.color = 'silver';
}
">
<select name="urldom">
<option value="">(select one)</option>
<option value=".com">.com</option>
<option value=".cjb.net">.cjb.net</option>
</select>
<input type="submit" value="Go!">
</p>
</form>
</body>
</html>
... where "jumpurl.cgi" should be a server-side script capable of taking the form values and redirecting the user to the appropriate page, without Javascript.Your document is missing a DOCTYPE and its <head> tag.
<form name="jumpurl1" onSubmit="return jumpit()">
<input type="text" size=30 name="jumpurl2" value="http://">
A block-level element is required here. Also, the name attribute is deprecated for this purpose.The <script> element requires a type attribute.
window.location=document.jumpurl1.jumpurl2.value + document.jumpurl1.jumpurl3.value
Accessing form elements this way is deprecated and may cause problems depending on the element names (you should use the forms and elements collections). You also (as a matter of good coding style) should try to use semicolons to unambiguously separate one statement from the next. The Javascript parser, if there are no semicolons, will attempt to form the longest statement possible, and this isn't always what you'd expect. Consider:
Code:
var a = 2
(new Foo()).bar()
This will throw an error "2 is not a function," because the interpreter will understand it as:
Code:
var a = 2(new Foo()).bar();
rather than the (probably expected)
Code:
var a = 2;
(new Foo()).bar();
Your code had two problems
1) jumpurl3 is not a child of jumpurl2
How is that a problem? There's no way one <input> can be the child of another :-\
Bookmarks