freeswami
02-13-2003, 01:46 PM
I want to copy the information entered in textbox1 in form1 to another html page containing textbox2 in form2. Any ideas on how to accomplish this?
Thanks,
Free
Thanks,
Free
|
Click to See Complete Forum and Search --> : Textboxes freeswami 02-13-2003, 01:46 PM I want to copy the information entered in textbox1 in form1 to another html page containing textbox2 in form2. Any ideas on how to accomplish this? Thanks, Free Nevermore 02-13-2003, 01:50 PM You can't do it in javascript unless one of the windows was opened by the other LAwebTek 02-13-2003, 02:04 PM I probably sound like the spokesperson for Cookie use lately but here's how I would do it: HTML Page 1 <html> <head> <script language="JavaScript" type="text/javascript"> function setCookie (name, value, expires) { if (!expires) expires = new Date(); document.cookie = name + "=" + escape (value) + "; expires=" + expires.toGMTString() + "; path=/"; } var expdate = new Date(); expdate.setTime (expdate.getTime() + (24 * 60 * 60 * 1000 * 365)); function saveData() { var data = document.form1.textbox1.value setCookie("textbox",data,expdate) } </script> </head> <body> <form name="form1"> <textarea name="textbox1" onChange="saveData()"></textarea> </form> </body> </html> HTML Page 2 <html> <head> <script language="JavaScript" type="text/javascript"> function getCookie (name) { var dcookie = document.cookie; var cname = name + "="; var clen = dcookie.length; var cbegin = 0; while (cbegin < clen) { var vbegin = cbegin + cname.length; if (dcookie.substring(cbegin, vbegin) == cname) { var vend = dcookie.indexOf (";", vbegin); if (vend == -1) vend = clen; return unescape(dcookie.substring(vbegin, vend)); } cbegin = dcookie.indexOf(" ", cbegin) + 1; if (cbegin == 0) break; } return null; } function delCookie(name) { document.cookie = name + "=; expires=Thu, 01-Jan-70 00:00:01 GMT" + "; path=/"; } function getData() { var data=getCookie("textbox") document.form2.textbox2.value = data delCookie("textbox") } </script> </head> <body onLoad="getData()"> <form name="form2"> <textarea name="textbox2"></textarea> </form> </body> </html> I changed the above code to delete the cookie, thanks cijori I was in a hurry. Nevermore 02-13-2003, 02:17 PM LAwebTek is right - I hadnt thought of using cookies. The second page needs to delete the cookie, though. Nevermore 02-14-2003, 01:01 PM You could use this : First page: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <META name="Author" content="Jacob Ward"> <title>Page 1</title> <script language="javascript" type="text/javascript"> <!-- function openWindow() { x = document.form.input1.value; y = document.form.input2.value; newWindow=window.open("page2.htm"); newWindow.form.output1.value=x; newWindow.form.output2.value=y; } --> </script> <noscript> <p>Your browser Desn't support JavaScript. You need Netscape Navigator 2.0 or better, or Microsoft Internet Explorer 3.0 or better</p> </noscript> </head> <body> <form NAME="form" action="post"> <input type="text" name="input1"> <input type="text" name="input2"> <input type="button" value="Copy" onClick="openWindow()"> </form> </body> </html> Second Page: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <META name="Author" content="Jacob Ward"> </head> <body> <form NAME="form" action="post"> <input type="text" name="output1"> <input type="text" name="output2"> </form> </body> </html> The form data will copy from pg 1 to pg 2. webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |