Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Submit Form to new page

Status
Not open for further replies.

wilsond001

Technical User
May 3, 2007
2
US
I am new to javascripting and am beating my head on the wall. I am trying to get the following page/code to work. When the submit button is pushed I am trying to get the information entered displayed in a new page. I think I have the basice but am not sure what to do for the page that is getting the data.

<html>
<head>
<script type="text/javascript">
function formSubmit()
{
document.getElementById("myForm").submit()
}
function formReset()
{
document.getElementById("myForm").reset()
}
function createTarget(t){
window.open("", t, "width=600,height=550");
return true;
}

</script>
</head>

<body bgcolor=#99CCFF >
<p>Please enter the requested information in the fields below, and then press the "Submit" button to submit the form. This information will allow us to better server you. Personnel data will not be shared with any outside parties</p>
<table >
<form name=myform type=post action=results.html onsubmit="return createTarget(this.target)" target="formtarget">

<!--<form id="myForm" action="results.html" method="get">-->
<tr><td>First name:</TD> <td> <input type="text" name="firstname" size="30"></td>
<tr><td>Last name:</td> <td><input type="text" name="lastname" size="30"></td>
<tr><td>Address:</TD> <td><input type="text" name="address1" size="30"></td>
<tr> <td></td> <td><input type="text" name="address2" size="30"></TD>
<tr><td>Area Code&Phone Number:</TD><td><input type="text" name="AreaCode" size="4"><input type="text" name="PhoneNumber" size="22"></td>
<tr><td>City:</td> <td><input type="text" name="city" size="30"></td>
<tr><td>State:</td> <td><input type="text" name="state" size="30" maxlength="2"></td>
<tr><td> Zip Code:</td> <td><input type="text" name="zip" size="30" maxlength="10"/></td>
<tr><td>Email Address:</TD> <td> <input type="text" name="email" size="50"></td>


<tr><tr><td><td>
<input type="submit" value="Preview" onclick="this.form.target='_blank';return true;"/>
<!--<input type="button" onclick="formSubmit()" value="Submit">-->
<input type="button" onclick="formReset()" value="Reset">

</form>
</body>

</html>


 
You need to use a server side language (Javascript is client side) to collect and display the results. Something ASP, PHP will do it and it's pretty simple.

Have a look for ASP or PHP "form submit's" on Google and you'll get a ton of results!

Good luck!

Nick
 
this is what Iam looking for but displaying on a new page instead of the bottom of this one.


<html>
<script type="text/javascript">
function preview(id1, id2){
var NewText = document.getElementById(id1).value;
splitText = NewText.split(/\n/).join("<br />");
var DivElement = document.getElementById(id2);
DivElement.innerHTML = splitText;
}

</script>
<form action="#">
<label>Name:</label>
<input type="text" id="name" onkeyup="preview('name', 'preview-name');" />

<label>Phone:</label>
<input type="text" id="phone" onkeyup="preview('phone', 'preview-phone');" />
</form>

<h2>Preview</h2>
<dl>
<dt>Name:</dt>
<dd id="preview-name"></dd>
<dt>Phone:</dt>
<dd id="preview-phone"></dd>

</dl>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top