Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
68
rated 0 times [  72] [ 4]  / answers: 1 / hits: 28229  / 12 Years ago, sun, october 14, 2012, 12:00:00

I have a HTML form (called form.html)and a JavaScript function such that when form is submitted, information in that form will be displayed.

Now I want all those info will be shown in new HTML page (called confirm.html), where should I go from?



NOTE: No php or sever-side or anything that really seriously related, it's just simple OFFLINE HTML-form problem, I just have 2 html place in same folder, I will test it on my browser, that's it. Only thing that I worry is how to use information from form.html file in confirm.html file since they are obviously separated.



Thank you very much, here is my form.html ( I dont have confirm.html yet)



    <HTML>
<HEAD>
<TITLE>Contact</TITLE>

<script type=text/javascript>

function addtext()
{
var fname = document.myform.first_name.value;
var lname = document.myform.last_name.value;
var email = document.myform.email.value;

document.writeln(Thank you! You have just entered the following:);
document.writeln(<pre>);
document.writeln(First Name : + fname);
document.writeln(Last Name : + lname);
document.writeln(Email Address : + email);
}
</script>
</HEAD>
<BODY>

<center>
<b>CONTACT US</b> <br></br>
<form name=myform>

<label for=first_name>First Name </label>
<input type=text name=first_name maxlength=50 size=30>
<br>
<label for=last_name>Last Name </label>
<input type=text name=last_name maxlength=50 size=30>
<br>
<label for=email>Email Address</label>
<input type=text name=email maxlength=80 size=30>
<br>
<input type=submit value=Submit onClick=addtext()>

</form>

</BODY>
</HTML>

More From » html

 Answers
4

Check out the window object of JavaScript: http://www.devguru.com/technologies/javascript/10855.asp



It has a property location, if you write into it, your browser will redirect:



window.location = http://www.google.com;


Note though, that this will not post your data to confirm.html. what you are trying to do without server-side scripting is not very useful. An HTML form will use CGI (common gateway interface) to send data to a server, that can then process the information. If you use the file:// protocol (as you seem to be doing; all local, static files), there is no server-side to process the data, only JavaScript.



If using the GET method of sending the data through CGI, you could extract the data from the URL using javaScript (as mentioned in another question). To do this, just update your form like this:



<form action=confirm.html method=get>


And do not put a onClick handler on the submit button, just let it submit.



Many other tools exist though that way more are suitable for the job: server-side scripting languages, examples include PHP, ASP, JSP. For local setups, your best best is using XAMPP.


[#82558] Friday, October 12, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dayanaracolleeng

Total Points: 7
Total Questions: 96
Total Answers: 104

Location: Mayotte
Member since Mon, Sep 12, 2022
2 Years ago
;