Jump to content

passing data javascript to php


kam_uoc

Recommended Posts

is it possible to pass some data to php?

 

my situation is simply follows.

 

let's say there are two files, main.php and child.php.

 

code for main.php

<?php
if (isset($_POST['str'])){
$text=$_POST['str'];
print "Text submited by child is:".$text;
}
else{
$text="";


?>
<HTML>
<HEAD>
<TITLE>Main Document</TITLE>
<SCRIPT type='text/JavaScript'>
function newWindow() {
window.open('child.php','sub','HEIGHT=200,WIDTH=200')
}
</SCRIPT>
</HEAD>
<BODY>
<FORM>
<INPUT TYPE='button' VALUE='New Window' onClick='newWindow()'>
</FORM>

</BODY>
</HTML>

--------------------------------

code for child.php

 


<HTML>
<HEAD>
<TITLE>A ChildDocument</TITLE>
</HEAD>
<BODY>
<FORM method='POST' action='main.php'>
Enter text to be copied to the main window:
<INPUT TYPE='text' name='str'>
<INPUT TYPE='submit' name='ok' value='Ok'>
</FORM>
</BODY>
</HTML>

 

--------------------------------

its obvious that it str passes to the main page. but the problem is it doesn't display b'cos no refresh happen. how can i refresh the main page when i click the ok button in the child page. or any other ways to achive this. remember i need the function newWindow() must be happen.

 

hope the ploblem is clear. please help. thanks.

Link to comment
https://forums.phpfreaks.com/topic/38600-passing-data-javascript-to-php/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.