Click to See Complete Forum and Search --> : Verify form, post and then move to new page


dezoconnor
03-17-2003, 03:31 AM
Help! I've been trying all weekend to get a form on my website to work correctly. All I want it to do is validate what's been entered and then post to an e-mail address and then and only then navigate to the next page. Any suggestions?

Heres what I have so far:

<html>

<head>
<title>Guestbook</title>
<link rel="stylesheet" type="text/css" href="../../css/css.css">


<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
function checkrequired (which) {
var pass=true;
if (document.images) {
for (i=0;i<which.length;i++) {
var tempobj=which.elements[i];
if (tempobj.name.substring(0,8)=="required") {
if (((tempobj.type=="text"||tempobj.type=="textarea")&&
tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
tempobj.selectedIndex==0)) {
pass=false;
break;
}
}
}
}
if (!pass) {
shortFieldName=tempobj.name.substring(8,30).toUpperCase();
alert("Please make sure the "+shortFieldName+" field was properly completed.");
return false;
}
else
return true;
}
// End -->

</script>



</head>

<body>


<table border="0" width="100%" bordercolor="#FF0000">
<tr>
<td width="100%">
<p align="center"><font color="#FF0000" face="Arial Black" size="7"><b></b></font></p>
</td>
</tr>
<tr>
<td width="100%">
<H3 align="center"><font color="#000000" face="Times New Roman" size="5">Please Sign In...</font></H3>
<form name =enableform onSubmit="return checkrequired(this)" method="post" action="mailto:">
<p align="center"><font face="Times New Roman" size="4">Forename: <input type="text" name="requiredforename"> Surname: <input type="text" name="requiredsurname">
</font>
</p>
<p align="center"><font face="Times New Roman" size="4">e-Mail: <input type="text" name="requirede-mail"> Age: <select name="requiredagecategory">
<option Selected> Pick an Option!
<option>1: Younger than 15
<option>2: 15-25
<option>3: 26-35
<option>4: 36-45
<option>5: 46-55
<option>6: 56-65
<option>7: 66+
</select>
</font>
</p>
<p align="center"><font size="4" face="Times New Roman">Please comment below</font>
<br>
<textarea name="requiredcomments" rows="6" cols="20"></textarea>
</p>
<p align="center">
<input type=submit value="Submit">
<input type=reset value="Start Over">
</p>
</form>
</td>
</tr>
<tr>
<td width=" align="center" 100%" rows="1" cols="20">
<p align="center">
</p>
</td>
</tr>
</table>

</body>

</html>

Thanks in advance

Nicodemas
03-17-2003, 06:22 AM
after the return true statement, insert this:

location = "http://some_url.com"

I guess that should work.

dezoconnor
03-17-2003, 06:41 AM
Nicodemas

Thanks for your reply unfortunately it didn't work. Any other suggestions. Its not an external link I'm sending them too but an internal hyperlink (a href), does this make a difference?

pyro
03-17-2003, 07:24 AM
Try add window.location.href = "yourpage.htm"; where Nicodemas suggested.

dezoconnor
03-17-2003, 07:36 AM
Still can't get it to work!

Nicodemas
03-17-2003, 09:38 AM
Oh.. duh! That damned return statement.

Erase it and put either of the above location statements..
preferably mine because mine is cooler :) MUAHAHAHA!

But on a serious note, you should consider not using a mailto: action. They have a lot of problems.

dezoconnor
03-17-2003, 10:08 AM
Thanks to Rob and Pyro for your help. Problem is now sorted.

Cheers:) :)