kanala Posted July 8, 2007 Share Posted July 8, 2007 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 More sharing options...
justsomeguy Posted July 8, 2007 Share Posted July 8, 2007 The easiest way is to put it in the session on page 1 and get it from the session on page 2.http://www.php.net/manual/en/features.sessions.php Link to comment Share on other sites More sharing options...
kanala Posted July 9, 2007 Author Share Posted July 9, 2007 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)?ThanksIs there an html way of doing it? Link to comment Share on other sites More sharing options...
jesh Posted July 9, 2007 Share Posted July 9, 2007 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 More sharing options...
kanala Posted July 9, 2007 Author Share Posted July 9, 2007 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 More sharing options...
jesh Posted July 9, 2007 Share Posted July 9, 2007 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 More sharing options...
kanala Posted July 9, 2007 Author Share Posted July 9, 2007 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 More sharing options...
kanala Posted July 9, 2007 Author Share Posted July 9, 2007 Does anyone know how to fix this? Link to comment Share on other sites More sharing options...
jesh Posted July 9, 2007 Share Posted July 9, 2007 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 More sharing options...
kanala Posted July 9, 2007 Author Share Posted July 9, 2007 Thanks so much jesh, it works!I'v been looking for this on Google for hours.Cheers Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.