Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing javascript variable to php over frames?

Status
Not open for further replies.

muratisik

Technical User
Dec 2, 2003
2
TR
Hello,
I am new to javascript and I am trying to use javascript over the frames to control a php function.
Here is my problem:

I have a web page which had two frames. In one of these frames there is a php function and a button:

<FORM name=&quot;testForm&quot; METHOD=GET ACTION=<?php echo $PHP_SELF?>>
<?php

$i = $_GET[&quot;temp&quot;];

if(isset($_GET[&quot;full&quot;]))
{
++$i;
}

echo $i;

?>
<INPUT TYPE=SUBMIT NAME=&quot;full&quot; VALUE=&quot;GO&quot;>
<INPUT TYPE=HIDDEN NAME=&quot;temp&quot; VALUE=&quot;<?php echo $i?>&quot;>

I am sure it si clear what this button does. What I am trying and failing to do is to have another button on the other frame that does the same thing this button does and also does it through the same php function. So this button on the other frame should somehow again set &quot;full&quot; and naturally since isset($_GET[&quot;full&quot;]) is true, $i will be incremented, as many times as the user presses this button.

Is it impossible to do something like this?

I dont know much php or javascript but my logic is that the user clicks ia button and sends the server's php a task and since javascript is also client side,just like the user himself, I thought javascript can do the same. The user tells javascript to do it and javascript tells the php to do it....

Any ideas?

Have a nice day.

Murat Isik

 
Are you asking how to increment a php variable with javascript, or how to submit a form with javascript.

Trying to submit the form, that will execute the php code, can be done by referencing the parent to the current document and then referencing the php frame by name and then the form by name.

if frame1 has the php code to be executed and frame2 has the button, then the buttons onClick method should read something like this:
Code:
  window.top.frame1.testForm.submit();

If I understand php correctly then it writes the HTML that the browser then reads. If this is the case then php can &quot;talk&quot; to javascript, but javascript cannot &quot;talk&quot; to php.

Post back, and let me know how it goes.

Randall2nd
 
Thank you for answering:)
I dont know much about web design but I guess it is &quot;submitting a form&quot; with javascript.
In every isuue, non-technical people (like me about javascript) use a rather silly non-techinal vocabulary when trying to describe technical issues...
So there is button I have at the end of the page:

<INPUT TYPE=SUBMIT NAME=&quot;full&quot; VALUE=&quot;GO&quot;>

I want to remove this button, put this page in a frame, put the button in another frame and get the same result when the button is pressed. As far as I gather from net sources, this is form submitting.

It is not only about incrementing a variable, maybe in the future the functions between the { } of if(isset) will do many other things. It is about controlling all these from another frame. Lets say five different functions, each between isset(&quot;f1&quot;), isset(&quot;f2&quot;) so on. With five buttons on the other frame I can choose which php job to trigger.

Off course there is the issue of &quot;keeping&quot; the variables in the memory. I am sure some of my future ideas will involve some variable kept in the memory through <INPUT TYPE=HIDDEN NAME=&quot;temp&quot; VALUE=&quot;<?php echo $i?>&quot;>

So that's how it goes...

Have a nice day

Murat Isik
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top