Jump to content

Move a variable to another page form


kanala

Recommended Posts

How would I set a variable e.g. var order="0099" on page 1Then move that variable to an input text box on page 2 (new window)?Thanks

Link to comment
Share on other sites

How would I set a variable e.g. var order="0099" on page 1Then move that variable to an input text box on page 2 (new window)?Thanks
Is there an html way of doing it?
Link to comment
Share on other sites

If you are opening up a new window to display page 2, then you can do something like this:

var win = window.open("page2.html");win.document.getElementById("myInput").value = "some value";

Link to comment
Share on other sites

If you are opening up a new window to display page 2, then you can do something like this:
var win = window.open("page2.html");win.document.getElementById("myInput").value = "some value";

Would this script go on page one?What goes where?And what would go on page 2 to get the value?ThanksEXAMPLE:Page 1<script LANGUAGE="JavaScript">var order="8999"</SCRIPT>Page 2<form><input type="text" name ="order number" value="document.write(order)"> OR SOMETHING?</form>
Link to comment
Share on other sites

It could look something like this:Page 1

<script type="text/javascript">var order = "8999";function gotoPage2(){	var win = window.open("page2.html");	win.document.getElementById("orderNumber").value = order;}</script><button onclick="gotoPage2();">Page 2</button>

Page 2

<form><input type="text" id="orderNumber" /></form>

Link to comment
Share on other sites

It could look something like this:Page 1
<script type="text/javascript">var order = "8999";function gotoPage2(){	var win = window.open("page2.html");	win.document.getElementById("orderNumber").value = order;}</script><button onclick="gotoPage2();">Page 2</button>

Page 2

<form><input type="text" id="orderNumber" /></form>

EDIT: Thanks actually it doesn't work, I'll check again.I'v checked but I don't understand why it is <input id> and not <input value>. It doesn't show up on page 2.
Link to comment
Share on other sites

It looks like the code is executing before the page2 finishes loading. Try changing the function to this:

function gotoPage2(){	var win = window.open("page2.html");	win.onload = function() { win.document.getElementById("orderNumber").value = order; }}

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...