Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.