I do pop modal window, and get data from myFrom
and save the email field value to my javascript in index.php
. How can I parsing the javascript value in to php and display it with echo, without refreshing the index.php
window ?
index.php
<script type="text/javascript">
function opennewsletter()
{ emailwindow=dhtmlmodal.open('EmailBox', 'iframe', 'newsletter.php', 'Newsletter Signup page', 'width=350px,height=200px,center=1,resize=0,scrolling=1')
emailwindow.onclose=function()
{ //Define custom code to run when window is closed
var theform =this.contentDoc.forms[0] //Access first form inside iframe just for your reference
var a = this.contentDoc.getElementById("emailfield").value; //Access form field with id="emailfield" inside iframe
return true //allow closing of window
}
} //End "opennewsletter" function
</script>
<a href="#" onClick="opennewsletter(); return false">Signup for our newletter</a>
<?php
$value = a; //I want above javascript variable 'a' value to be store here
echo $value;
?>
newsletter.php
<h4>Sign up for our newsletter!</h4>
<form id="myform" name="myform" method="post" >
<p>Enter your email address please:<br>
<input type="text" id="emailfield" name="emailfield" size="30" />
<input type="submit" id="submit" name="submit" value="Ok" onClick="parent.emailwindow.hide()" /></p>
</form>