Javascript creating a username using inputs - javascript

I have a form in which the user inputs various information. The input chosen name allows the user to enter a username of choice but a HIDDEN INPUT needs to be integrated so that a system username is created.
The system username is generated on page submit by a javascript function, and it consists of the first alphabetic characters found in the Family name, street address, Given name; the numerical day of the month; and the numerical seconds field of the time of submission. E.g.: A user registers with name Bernardo O’Higgins, address 213 Liberator St, at 12:31:16 on 25 April 2014. His system username is
OLB2516. Just so i can see if it works, at the moment the ssytem username is not hidden but just a normal text box.
I am totally lost as i do not know how to go about this and hoping somebody can help me? Here is my php file with form integrated.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<link rel="stylesheet" type="text/css" href="stylesheet.css" />
<title>Registration</title>
</head>
<body>
<?php
$conn = mysql_connect("localhost", "....", ".....");
mysql_select_db("tipping291", $conn)
or die ('Database not found ' . mysql_error() );
mysql_close($conn);
?>
<div id="container">
<div id="header">
<h1>Registration</h1></div>
<div id="menu">
<h2>Homepage</h2><br />
<h2>Registration</h2><br />
<h2>User Login</h2><br />
<h2>Administrator Login</h2><br />
<h2>Tipping</h2><br />
<h2>Terms & Conditions</h2><br />
</div>
<form id="rego" action="<?php echo
htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post" onSubmit="return validateForm()">
<label>Given Name:</label> <input type="text" name="gname"><br />
<br />
<label>Middle Name: </label><input type="text" name="mname"><br />
<br />
<label>Family Name:</label> <input type="text" name="surname"><br />
<br />
<label>Chosen Username:</label> <input type="text" name="username"><br />
<br />
<label>Address:</label> <input type="text" name="address"><br />
<br />
<label>Postcode: </label><input type="text" name="postcode"><br />
<br />
<label>State:</label> <input type="text" name="state"><br />
<br />
<label>Tel number: </label><input type="text" name="tel"><br />
<br />
<label>Password:</label> <input type="password" name="password"><br />
<br />
<label>Password confirmation:</label> <input type="password" name="passconfirm"><br />
<br />
<label>System username</label> <input type="text" name="susername" >
<input type="submit" value="submit">
</div>
</form>
</body>
</html>
CAN SOMBODY PEASE HELP ME!!!!! I HAVENT HAD ANY SUCCESSS

I think the code found here is more suitable to generate a random string (you can put 20 characters instead of 10)
You can also just use md5() in the time or user email...
And you don't need to worry to create it in javascript, if this is random generated you can do that in php.
If you really need to do in javascript... there's CaffGeek answer in this post.. who could help you

Add the below code before closing } of function validateForm() { and try
var username = '';
var date = new Date();
$.each(['surname', 'address', 'gname'], function() {
username += $.trim($('input[name="' + this + '"]').val().replace(/\d+/g, '')).substring(0, 1);
});
username += date.getDate() + '' + date.getSeconds();
$('input[name="susername"]').val(username);
jsBin

Related

Replacing some JS lines with PHP

I have a form below which uses javascript to perfom a maths equation. But i want the equation hidden, so that means replacing the JS maths equation line (var result), with a new php script. I am thinking the php code should be outside of the JS tags, perhaps using the JS variables. But i dont know much about php. I am not trying to learn php, i am just trying to get a working form, so please no convoluted lessons on how php works. I want to avoid using node js and doing ajax calls etc. If not possible please say so.
<html>
<head>
<script>
function bmi () {
var height = Number(document.getElementById("height").value);
var weight = Number(document.getElementById("weight").value);
var result = weight / (height * height);
document.getElementById("result").innerHTML = "Your score is : " + result;
}
</script>
<title>Page Title</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
</head>
<body>
<form>
<h4>BMI</h4>
<input id="height" type="text" placeholder="height in meters or feet" />
<br />
<br />
<input id="weight" type="text" placeholder="weight in kgs or lbs" />
<br />
<br />
<input class = "submit" type="button" value="Submit" onclick="bmi()" />
<p id="result">Result</p>
</form>
</body>
</html>
<?php
function bmi($height, $weight) {
$height = floatval($height);
$weight = floatval($weight);
return $weight / ($height * $height);
}
?>
<html>
<head>
<title>Page Title</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
</head>
<body>
<form action="" method="POST">
<h4>BMI</h4>
<input id="height" name="height" type="text" placeholder="height in meters or feet" value="<?php echo isset($_POST['height']) ? $_POST['height'] : ''; ?>" />
<br/>
<br/>
<input id="weight" name="weight" type="text" placeholder="weight in kgs or lbs" value="<?php echo isset($_POST['weight']) ? $_POST['weight'] : ''; ?>" />
<br/>
<br/>
<input class="submit" type="submit" value="Submit"/>
<?php if (!empty($_POST['height']) && !empty($_POST['weight'])) : ?>
<p>Your score is <?php echo bmi($_POST['height'], $_POST['weight']); ?></p>
<?php endif; ?>
</form>
</body>
</html>
Without AJAX call, its not possible i guess if u want to use php.
Another way is, you can use angular to get your problem's solution.

Function keeps returning NaN, tuition calculator

I can't seem to get my function right.....It's a tuition calculator. At this point the residency and semesters don't matter. It's just credits * credit cost, but it keeps returning NaN.
<!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>
<meta charset="utf-8" />
<title>Greendale Community College</title>
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
var numCredits = 0;
var creditCost = 302;
var instate = 0;
var outstate = 0;
var international = 0;
var tuitionCost = number;
function calcTuition(numCredits, creditCost) {
var tuitionCost = numCredits * creditCost;
document.write("Your tuition cost is $" + tuitionCost);
}
</script>
</head>
<body>
<p><center><font face="impact" font size="200" color="green">Greendale Community College</font></center></p>
<center><img src="greendale.jpg" alt="greendale" width="512" height="256"/></center>
<h1><center>Tuition Calculator</center></h1>
<form name="calculator" action="" method="get">
<h2>Semester</h2>
<h3>(choose a semester)</h3>
<input type="radio" name="semesterFall"/> Fall 2018 <br />
<input type="radio" name="semesterSpring"/> Spring 2018 <br />
<input type="radio" name="semesterSummer"/> Summer 2018 <br />
<h2>Residency</h2>
<h3>(choose your residency)</h3>
<input type="radio" name="instate" /> In-State <br />
<input type="radio" name="outstate" /> Out-of-State <br />
<input type="radio" name="international" /> International <br />
<h2>Credits</h2>
<h3>(enter your number of credits)</h3>
<input type="text" name="numCredits" size="2" onchange="calcTuition(numCredits, creditCost)"/> Credits <br />
<input type="button" name="tuition" onclick="window.alert(calcTuition(numCredits, creditCost))" value="Calculate your Tuition" />
</form>
</body>
</html>
I took a look at what's going on and it looks like you're trying to call numCredits when it is not a valid number. The exact type of it is $[object HTMLInputElement]. Addition between an HTMLInputElement and Integer is undefined behavior and as a result the value that you obtain is NaN.
One possible solution is using the document.getElementbyId method to return the actual element and then you can perform any operation on them.
PS: You should try and debug your own functions, you mentioned you're new to this but it would be great to set up some print statements or use an interactive debugger to see exactly where the problem is occurring. This way you can troubleshoot it and understand the problem at the same time.
<script type="text/javascript">
var c_amount = 302;
function calcu_Tuition(Credits, c_amount) {
//var Credits
var Credits = document.getElementById("Credits").value //it will get the value of Credits text box and be transfer to Credits variable.
var tuition = 0;
var tuition = Credits * c_amount;
document.write("Your tuition cost is $" + tuition);
}
</script>
<body>
<h2>Credits</h2>
<h3>(enter your number of credits)</h3>
<input type="text" id="Credits" size="2" onchange="calcu_Tuition(Credits, c_amount)"/> Credits <br>
<button id="tuition" onclick="calcu_Tuition(c_amount)">Calculate your Tuition"</button>
</form>
</body>

"Data entered successfully" message to appear on same page of insert form?

I have an insert form where I can submit data into my database.
Here's my code:
<form action="insert_backend.php" method="POST" enctype="multipart/form-data">
<!-- Method can be set as POST for hiding values in URL-->
<h2>Form</h2>
<label for="uploadedimage">Small image to upload: </label>
<input type="file" name="uploadedimage" id="uploadedimage"/><br />
<label>Date:</label>
<input class="input" name="date" type="text" value=""><br />
<label>Retrace:</label>
<input class="input" name="retrace" type="text" value=""><br />
<label>Start of Swing Trade:</label>
<input class="input" name="start_of_swing_trade" type="text" value=""><br />
<label>End of Swing Trade:</label>
<input class="input" name="end_of_swing_trade" type="text" value=""><br />
<label>Bull flag:</label>
<input class="input" name="bull_flag" type="text" value=""><br />
<label>Bear flag:</label>
<input class="input" name="bear_flag" type="text" value=""><br />
<label>EMA Crossover:</label>
<input class="input" name="ema_crossover" type="text" value=""><br />
<label>Trading Instrument:</label>
<input class="input" name="trading_instrument" type="text" value=""><br />
<input class="submit" name="submit" type="submit" value="Insert">
</form>
Here's a snippet of the "Success" message on the php that is used to process the data submitted to the database:
$stmt->bind_param('sssssssss',$target_path, $date, $retrace, $start_of_swing_trade, $end_of_swing_trade, $bull_flag, $bear_flag, $ema_crossover, $trading_instrument);
if(!$stmt){ exit("bind failed");}
//will return 0 if fail
if($stmt->execute() != 0){
echo "New record created successfully";
}else{ echo "Failed to insert new record";}
Whenever I Insert data, I get the "New record created successfully" message on the insert_backend.php page, which is the php file used to process and submit the data, but not on the actual form page used to insert data. Usually when you use a form to send a message to someone or to send data into a database, the form resets itself and you get a "success" message that shows at the bottom of the form without getting redirected to another page. But the code I have redirects me to the page that is used to process the data. how do I get it to show the "success" message on the same page as the form itself?
My FULL insert form code (with the php redirect check solution in it):
<!DOCTYPE html>
<html>
<head>
<title>Chart Submission Form</title>
<link href="insert.css" rel="stylesheet">
</head>
<body>
<div class="maindiv">
<!--HTML Form -->
<div class="form_div">
<div class="title">
<h2>Insert Data In Database Using PHP.</h2>
</div>
<form action="insert_backend.php" method="POST" enctype="multipart/form-data">
<!-- Method can be set as POST for hiding values in URL-->
<h2>Form</h2>
<label for="uploadedimage">Small image to upload: </label>
<input type="file" name="uploadedimage" id="uploadedimage"/><br />
<label>Date:</label>
<input class="input" name="date" type="text" value=""><br />
<label>Retrace:</label>
<input class="input" name="retrace" type="text" value=""><br />
<label>Start of Swing Trade:</label>
<input class="input" name="start_of_swing_trade" type="text" value=""><br />
<label>End of Swing Trade:</label>
<input class="input" name="end_of_swing_trade" type="text" value=""><br />
<label>Bull flag:</label>
<input class="input" name="bull_flag" type="text" value=""><br />
<label>Bear flag:</label>
<input class="input" name="bear_flag" type="text" value=""><br />
<label>EMA Crossover:</label>
<input class="input" name="ema_crossover" type="text" value=""><br />
<label>Trading Instrument:</label>
<input class="input" name="trading_instrument" type="text" value=""><br />
<input class="submit" name="submit" type="submit" value="Insert">
</form>
<?php
if (isset($_GET['success']) && $_GET['success']) {
echo "New record created successfully";
} else if (isset($_GET['success']) && !$_GET['success']) {
echo "Failed to insert new record";
}
?>
</div>
</div>
</body>
</html>
Updated my PHP code to include the header location:
$sql = "INSERT into charts (charts_URL, charts_date, charts_retrace, charts_start_of_swing_trade, charts_end_of_swing_trade, charts_bullflag, charts_bearflag, charts_ema_crossover, charts_trading_instrument) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";
// s = string, i = integer, d = double, b = blob
//preparing statement
$stmt = $conn->prepare($sql);
if(!$stmt){ exit("prepare failed");}
//binding param
$stmt->bind_param('sssssssss',$target_path, $date, $retrace, $start_of_swing_trade, $end_of_swing_trade, $bull_flag, $bear_flag, $ema_crossover, $trading_instrument);
if(!$stmt){ exit("bind failed");}
//will return 0 if fail
if($stmt->execute() != 0){
$success = true;
}else{
$success = false;
}
header('location:insertchart.php?success='.$success);
exit;
}
}
}
?>
The FINAL code (actually a snippet) that made everything work:
if($stmt->execute() != 0){
$success = true;
header('Location:http://mlsinc.net/chart-submission/insertchart.php?success='.$success);
}else{
$success = false;
header('Location:http://mlsinc.net/chart-submission/insertchart.php?success='.$success);
}
}
//close connection
$conn->close();
Try with -
$stmt->bind_param('sssssssss',$target_path, $date, $retrace, $start_of_swing_trade, $end_of_swing_trade, $bull_flag, $bear_flag, $ema_crossover, $trading_instrument);
if(!$stmt){ exit("bind failed");}
//will return 0 if fail
if($stmt->execute() != 0){
$success = true;
}else{
$success = false;
}
header('location:yourform.php?success='.$success);
exit;
On you form page add a check for it -
if (isset($_GET['success']) && $_GET['success']) {
echo "New record created successfully";
} else if (isset($_GET['success']) && !$_GET['success']) {
echo "Failed to insert new record";
}
To show the message on form page
Store the message in session after inserting the row(since you are redirecting page)
I think the soultion suggested by sgt BOSE will work for you. But instead of passing a "success" GET parameter back to your page containing form, you should use a session variable because the $_GET['success'] will re-print the message if user reloads the window.
Once you print the result stored in session variable make sure to unset it.
Ok I see your problem here, it's actually pretty simple.
the way it works is that the message would be declared inside of the script tag
so you should do something like this so it will call the message.
<html>
<head>
<script type="text/javascript">
//Put the javascript function you want the button to do Here
function show_alert()
{
alert("Form Succesfully Submited");
}
</script>
</head>
<body>
<form action="insert_backend.php" method="POST" enctype="multipart/form-data">
<!-- Method can be set as POST for hiding values in URL-->
<h2>Form</h2>
<label for="uploadedimage">Small image to upload:</label>
<input type="file" name="uploadedimage" id="uploadedimage" />
<br />
<label>Date:</label>
<input class="input" name="date" type="text" value="">
<br />
<label>Retrace:</label>
<input class="input" name="retrace" type="text" value="">
<br />
<label>Start of Swing Trade:</label>
<input class="input" name="start_of_swing_trade" type="text" value="">
<br />
<label>End of Swing Trade:</label>
<input class="input" name="end_of_swing_trade" type="text" value="">
<br />
<label>Bull flag:</label>
<input class="input" name="bull_flag" type="text" value="">
<br />
<label>Bear flag:</label>
<input class="input" name="bear_flag" type="text" value="">
<br />
<label>EMA Crossover:</label>
<input class="input" name="ema_crossover" type="text" value="">
<br />
<label>Trading Instrument:</label>
<input class="input" name="trading_instrument" type="text" value="">
<br />
<!--This is where you tell the script where to load the (ID) for example im using a simple message for you what you need to do is make the id im sure you know how to create a simple (ID) inside of a java ,heck im thirteen im about an expert on it if i can do im sure you can! :) :)
anyway inside the div tag make it look like this: <div id=("PUT ID IN HERE") >
then put you function in the script for wha you want it to do hope this helped you have a nice day!-->
<div>
<input class="button" name="submit" type="submit" onclick="show_alert()" value="Submit">
</div>
</form>
</body>
</html>
Hope that this helps if not dont hate lol.

formObject.submit() is not working

I have a simple form and I am using javascript for validation of data entered. I can't understand why document.getElementById("submitform").submit() is not working. Below is my code. Thank you for your help.
<!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>
<script type="text/javascript">
function checkSyntax(){
jsid=document.getElementById("sid").value;
jname=document.getElementById("name").value;
jemail=document.getElementById("email").value;
jgpa=document.getElementById("gpa").value;
var noError=true;
var Regsig=/^[2][0-9]{8}$/;
var Regn=/^[a-zA-Z]{2,25}$/;
var Rege=/^[a-zA-Z]+[_]?[a-zA-Z]*[#][a-zA-Z]+[.](net|com|edu.sa)$/;
var Regg=/^[1-4]+[.][0-9]+/;
if(!Regsig.test(jsid)){
alert("The student ID must be all numbers and of length 9");
noError=false;
}
if(!Regn.test(jname)){
alert("Name must be alphabets of min length 3 and max 25");
noError=false;
}
if(!Rege.test(jemail)){
alert("Wrong email format");
noError=false;
}
if(!Regg.test(jgpa)){
alert("Wrong GPA format");
noError=false;
}
if(noError){
**document.getElementById("submitform").submit();**
}
}
function checkRetrieve(Sid2,Name2){
var Regsig=/(|[2][0-9]{8})/;
var Regn=/(|[a-zA-Z]{2,25})/;
var error=true;
if(!Regsig.test(sid.value)){
alert("The student ID must be all numbers and of length 9");
error=false;
}
if(!Regn.test(name.value)){
alert("Name must be alphabets of min length 3 and max 25");
error=false;
}
if(Sid2.value!="" && Name2.value!=""){
alert("you can only use on of the two fields for your query");
Sid2.value="";
Name2.value="";
error=false;
}
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<h1>Web-Based Application for Student Academic Records</h1>
<p> Add a new student</p>
<body>
<form id="submitform" name="form1" method="post" action="stacademic.php">
Student ID:<input type="text" size="26" maxlength="9" name="SID"id="sid"/><br /><br />
Name:<input type="text" size="30" maxlength="50" name="NAME" id="name"/><br /><br />
Email:<input type="text" size="30" maxlength="50" name="EMAIL" id="email"/><br /><br />
Major: <select id="major" name="MAJOR">
<option>Computer Engineering<option/>
<option>Computer Science<option/>
<option>Electrical Engineering<option/>
<option>Mechanical Engineering<option/>
<option>Software Engineering<option/>
</select><br />
<br />
GPA:<input type="text" size="30" maxlength="5" name="GPA" id="gpa"/><br /><br />
<input type="submit" value="submit" onclick="checkSyntax()" name="submit"/><br />
</form><br />
<p> Retrieve student GPA either Student ID or Student Name: </p>
<form id="retrieveform" onSubmit="return checkRetrieve(this.sid2,this.name2);" method="post" action="stacademic.php">
Student ID:<input type="text" size="26" maxlength="9" name="SID2" id="sid2"/><br /><br />
Name:<input type="text" size="30" maxlength="50" name="NAME2" id="name2"/><br /><br />
<input type="submit" value="Retrieve Results" name="submit2"/><br />
</form>
</body>
</html>
When you click the button, the form is already being submitted.
What you should to is to assign the checkSyntax to the onsubmit event and then return true if everything was right or return false if errors occurs. If the function in the onsubmit event returns false, the form is not submitted.
Alex is right, your submit button is submitting the form. You should use the onSubmit event on your form and if validation fails, have it return false, which will cancel the submit. Also, it is not a good idea to use onclick because if the user submits the form by hitting enter, the function will be bypassed.
<form id="submitform" name="form1" method="post" action="stacademic.php" onSubmit="checkSyntax()">

How to use a cookie to detect if the user has already submitted the form?

I'm not looking for someone to do my work for me... I need help/advice.
I need to:
Modify the form page so that when the JavaScript function has verified that all of the required fields have been filled, a cookie is added to the user's computer. If the same user attempts to fill out the form a second time, the user will be directed to a separate HTML page advising them that they have already submitted the form.
What am I doing wrong?
This is my form:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Request Form</title>
<meta name="Description" content="This webpage is for Customer Demographics" />
<meta name="Keywords" content="Rhonda , email, " />
<meta name="author" content="Rhonda " />
<meta name="copyright" content="Copyright 2010 Rhonda , All Rights Reserved" />
<meta name="robots" content="all" />
<meta name="revisit-after" content="15 days" />
<meta name="rating" content="safe for kids" />
<script>
<!-- page to go to if cookie -->
go_to = "Submit.html";
num_days = -1;
function ged(noDays){
var today = new Date();
var expr = new Date(today.getTime() + noDays*24*60*60*1000);
return expr.toGMTString();
}
function readCookie(cookieName){
var start = document.cookie.indexOf(cookieName);
if (start == -1){
document.cookie = "seenit=yes; expires=" + ged(num_days);
} else {
window.location = go_to;
}
}
readCookie("seenit");
</script>
<script type="text/javascript" >
function verify() {
var themessage = "You are required to complete the following fields: ";
if (document.form.first.value=="") {
themessage = themessage + " - First Name";
}
if (document.form.middle.value=="") {
themessage = themessage + " - Middle Initial";
}
if (document.form.last.value=="") {
themessage = themessage + " - Last Name";
}
if (document.form.street.value=="") {
themessage = themessage + " - Street";
}
if (document.form.city.value=="") {
themessage = themessage + " - City";
}
if (document.form.state.value=="") {
themessage = themessage + " - State";
}
if (document.form.zip.value=="") {
themessage = themessage + " - Zip Code";
}
if (document.form.email.value=="") {
themessage = themessage + " - E-mail";
}
if (document.form.areacode.value=="") {
themessage = themessage + " - Area Code";
}
if (document.form.telephone.value=="") {
themessage = themessage + " - Telephone";
}
if (themessage == "You are required to complete the following fields: ") {
document.form.submit();
}
else {
alert(themessage);
return false;
}
}
</script>
</head>
<body>
<body style="background-color:lightsteelblue">
<h1>
Welcome customer.
<br />
<br />
<br />
Please enter the following details in order
to be added to our preferred customer mailing list:
<br />
<br />
<br />
</h1>
<!--This code builds the form -->
<form name=form method="post" action="">
<!--Personal information: -->
<form action="">
<fieldset>
<legend>Personal Information:</legend>
<br /><br />
First Name:<input type=text name="first" size="20"> <br /><br /><br />
Middle Initial:<input type=text name="middle" size="3"><br /><br /><br />
Last Name:<input type=text name="last" size="20"> <br /><br />
<br />
</fieldset>
<br /><br />
<form action="">
<fieldset>
<legend>Address:</legend>
<!--Address: -->
Street: <input type=text name="street" size="30"><br /><br />
City: <input type=text name="city" size="30"><br/><br />
State:<input type=text name="state" size="2"><br/><br />
Zip Code: <input type=text name="zip" size="7"><br /><br />
<br />
</fieldset>
<br /><br />
<!--Contact Information: -->
<form action="">
<fieldset>
<legend>Contact Information:</legend>
Email Address:<input type=text name="email" size="25" />
<br /><br />
Area Code:<input type=text name="areacode" size="3" /><br /><br />
Telephone Number:<input type=text name="telephone" size="7" />
<br />
<br />
</fieldset>
<br /><br /><br />
<!--NOTES
This part was not mandantory. I was just trying some of the extra ways of adding input that the book discussed-->
<form action="">
<fieldset>
<legend>Extra Credit:</legend>
<p>
Gender:
<br />
<input type="radio" name="sex" value="male" /> Male<br />
<input type="radio" name="sex" value="female" /> Female
</p>
<p>
How did you hear about us?
<br />
<input type="checkbox" name="Friend" value="Friend" /> From a friend
<br />
<input type="checkbox" name="Advertisement" value="Advertisement" /> Store Advertisement
<br />
<input type="checkbox" name="Online" value="Online" /> From Online
<br />
<input type="checkbox" name="Other" value="Other" /> Other
<br />
</p>
<p>
How do you wish to be contacted?
<br />
<form action="">
<select name="contact">
<option value="telephone">Telephone</option>
<option value="E-mail">E-mail</option>
<option value="Snail-mail">Snail-mail</option>
</select>
<br />
<br />
</fieldset>
</p>
</form>
<form action="" onSubmit="return verify()" method="post">
<input type="submit" name="submit" value="Submit">
<input type=reset value="Clear Form"><br>
</form>
<!--Back to top -->
<p>Back to Top</p>
</body>
</html>
The first thing to note is that nested <form> tags are not legal HTML. You only need one form tag to wrap everything that you want to submit from before the first <input> to after the submit button. Add your onSubmit handler to that form tag.
Additionally, your first script tag:
A) Does not have a type="text/javascript" attribute (which is, I believe required if your are using XHTML.)
B) Is using an HTML comment <!-- --> rather than a JavaScript comment // or /* */, which is probably throwing an error and killing everything that happens below it.
Fix those two things, and if it's still not working, come back and edit the question, adding more information about the errors you're seeing and what you've tried so far to fix them. :-)

Categories