Javascriptでフォームの遷移をする際にs1.htmlのテキストボックスの値をs2.htmlに受け渡して表示したいと思っております。
ソースは以下になっております。
・s1.html
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title> <script type="text/javascript" language="javascript"> function onButtonClick() { target = document.getElementById("output"); target.innerText = document.id_form1.id_textBox1.value;//これでもOK } </script> </head> <body> <form name="form1" id="id_form1" action="s2.html"> <input name="textBox1" id="id_textBox1" type="text" value="" /> <input type="button" value="Exec" onclick="location.href='s2.html'" /> <input type="button" value="ok" onclick="onButtonClick();" /> </form> <hr/> <div id="output"></div> </body> </html>
・s2.html
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title> <script type="text/javascript" language="javascript"> function onButtonClick2() { target = document.getElementById("output2"); target.innerText = document.id_form2.id_textBox2.value;//これでもOK } </script> </head> <body> <form name="form2" id="id_form2" action=""> <input name="textBox2" id="id_textBox2" type="text"/> <input type="button" value="ok" onclick="onButtonClick2();" /> </form> <hr/> <div id="output2"></div> </body> </html>
よろしくお願いいたします。