[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

communication between two php pages

Posted on 2006-06-13
3
Medium Priority
?
430 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
  • 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
The viewer will learn how to dynamically set the form action using jQuery.
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
Course of the Month18 days, 3 hours left to enroll

830 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