sungpeng Posted November 27, 2012 Share Posted November 27, 2012 <script> function open_win() { window.open ("chats.php","mywindow","menubar=1,resizable=1,width=350,height=500"); } </script> <form name="form" method="post" onsubmit="return open_win();"> <select name="cpid"> <option value="2">2</option> </select> <input type="submit" name="talk" value="Chat"> </form> Please help. I can't get the value $_POST[cpid] from chats.php. Quote Link to comment https://forums.phpfreaks.com/topic/271249-windowopen-with-form/ Share on other sites More sharing options...
Iluvatar+ Posted November 27, 2012 Share Posted November 27, 2012 You coulds pass the value of the select into the js function and append it on the URL and dectect the value on the pop-up using $_GET Quote Link to comment https://forums.phpfreaks.com/topic/271249-windowopen-with-form/#findComment-1395561 Share on other sites More sharing options...
Iluvatar+ Posted November 27, 2012 Share Posted November 27, 2012 function open_win(val) { window.open ("chats.php?id="+val,"mywindow","menubar=1,resizable=1,width=350,height=500"); } Quote Link to comment https://forums.phpfreaks.com/topic/271249-windowopen-with-form/#findComment-1395562 Share on other sites More sharing options...
sungpeng Posted November 27, 2012 Author Share Posted November 27, 2012 var val = "<?php Print $_REQUEST[cpid]; ?>"; The first attempt I clicked submit button the value passed to the function open_win. To my surprise the first time "val" return as 0 in value. The second attempt I clicked submit button the value of the first attempt is reflected out from "val" Please help.. Quote Link to comment https://forums.phpfreaks.com/topic/271249-windowopen-with-form/#findComment-1395591 Share on other sites More sharing options...
sungpeng Posted November 27, 2012 Author Share Posted November 27, 2012 (edited) I think when the form called out open_win(), the $_REQUEST[cpid]; is empty so it reflect the empty value first instead of the value that passed from the form which is 2. Anyway to solve it ? Edited November 27, 2012 by sungpeng Quote Link to comment https://forums.phpfreaks.com/topic/271249-windowopen-with-form/#findComment-1395648 Share on other sites More sharing options...
sungpeng Posted November 27, 2012 Author Share Posted November 27, 2012 anyway thank for helping. Quote Link to comment https://forums.phpfreaks.com/topic/271249-windowopen-with-form/#findComment-1395691 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.