kokokav
08-31-2003, 12:08 AM
I'm a javascript beginner and would love some help modifying a code. I'm trying to do a simple form-based redirect so that the info in the "user id" form field gets appended to the end of a URL (i.e., when someone puts in "Bob" as their username, they get redirected to http://www.website.com/Bob). This is what I have:
<script language="javascript">
<!-- Begin
function Login(form) {
var username = form.username.value;
var server = form.server.value;
if (username && server) {
var htsite = "http://" + server + username;
window.location = htsite;
}
else {
alert("Please enter your username.");
}
}
// End -->
</script>
<form name="login" method="post" action="http://www.website.com/index_error.htm">
<input type="hidden" name="server" value="www.website.com/">
User ID:
<input type="textfield" name="username" size="14">
<input type=button value="Login!" onClick="Login(this.form)" name="button">
</form>
It works fine, but what I now want to do is have the redirect open in a new page. Any suggestions???
--Kaveh
(btw, I threw in the index_error.htm in the post because if I filled out the id box and hit Enter instead of clicking the button, I got a "post action not defined" error)
<script language="javascript">
<!-- Begin
function Login(form) {
var username = form.username.value;
var server = form.server.value;
if (username && server) {
var htsite = "http://" + server + username;
window.location = htsite;
}
else {
alert("Please enter your username.");
}
}
// End -->
</script>
<form name="login" method="post" action="http://www.website.com/index_error.htm">
<input type="hidden" name="server" value="www.website.com/">
User ID:
<input type="textfield" name="username" size="14">
<input type=button value="Login!" onClick="Login(this.form)" name="button">
</form>
It works fine, but what I now want to do is have the redirect open in a new page. Any suggestions???
--Kaveh
(btw, I threw in the index_error.htm in the post because if I filled out the id box and hit Enter instead of clicking the button, I got a "post action not defined" error)