Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

communication between two php pages

Posted on 2006-06-13
3
Medium Priority
?
423 Views
Last Modified: 2011-10-03
Hi experts,

actually i am not sure is this a php question, or it's a javascript question...

for example, i have a page called form.php, basically it's a form asking for user's input

then i have another page called call.php, it contains a list of names....  what i want is that when a user clicked on the list of name in call.php, the value of that name will be passed into form.php, and form.php should be updated by itself ...    i saw this somewhere on the web actually, but i am not sure how to get this done, either via php or javascript?

thanks a lot!!

airok
0
Comment
Question by:airok
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 49

Expert Comment

by:Roonaan
ID: 16892741
You can use javascript to pass the value from call.php to form.php and then let the form in form.php submit itself to refresh the page. (You can also just refresh the page, but I expect you need to submit the form).

Are your pages within a frameset or do they have an opener/popup relationship?

-r-
0
 

Author Comment

by:airok
ID: 16892791
it's a opener/popup relationship

do u have a example javascipt can let me take a look for reference?

i would like to know how to do this if it's a frameset too...  ;)
many thanks!!

sorry i am not familiar with javascript at all...
0
 
LVL 49

Accepted Solution

by:
Roonaan earned 2000 total points
ID: 16892825
When call.php is the popup you can have this script:
[form.php]
<form name="mainForm">
  <input type="text"  name="callField" />
  <input type="button" onclick="window.open('call.php');" value="Load call.php" />
</form>
[call.php]
<script type="text/javascript">
function setFormField(field, value, submit) {
  frm = window.opener.document.forms.mainForm;
  frm.elements[field].value = value;
  if(submit) frm.submit();
}
</script>

<a href="javascript:setFormField('callField', 'Name 1', true);">Name 1</a><br/>
<a href="javascript:setFormField('callField', 'Name 2', true);">Name 2</a><br/>
<a href="javascript:setFormField('callField', 'Name 3', true);">Name 3</a><br/>
<a href="javascript:setFormField('callField', 'Name 4', true);">Name 4</a><br/>
<a href="javascript:setFormField('callField', 'Name 5', true);">Name 5</a><br/>
<a href="javascript:setFormField('callField', 'Name 6', true);">Name 6</a><br/>
<a href="javascript:setFormField('callField', 'Name 7', true);">Name 7</a><br/>

When you are having frames you only have to change the javascript:

<script type="text/javascript">
function setFormField(field, value, submit) {
  frm = parent.otherFrameName.document.forms.mainForm;
  frm.elements[field].value = value;
  if(submit) frm.submit();
}
</script>

Hope this helps,

-r-
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question