Current location: Hot Scripts Forums » General Web Coding » JavaScript » Reaaly stuck about javascript over frames

Reaaly stuck about javascript over frames

Reply
  #1 (permalink)  
Old 12-02-03, 08:01 AM
muratisik muratisik is offline
New Member
 
Join Date: Dec 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Reaaly stuck about javascript over frames

Hello,
I am new to javascript and I am trying to use javascript over the frames to control a php function.
I will attach some piece of example I have but couldnot get to work, but also I want to express my problem verbally too:

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

<FORM name="testForm" METHOD=GET ACTION=<?php echo $PHP_SELF?>>
<?php

$i = $_GET["temp"];

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

echo $i;

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

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 "full" and naturally since isset($_GET["full"]) 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
Attached Files
File Type: zip newtest.zip (833 Bytes, 587 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 12-14-03, 12:58 PM
psyon psyon is offline
Newbie Coder
 
Join Date: Dec 2003
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Well, just to point out what may be known already. PHP code is never sent to a visitors browser, it is all parsed out before the content is sent. There is no direct way to make javascript interact with php, aside from just passing form variables as you are doing.

Since the frames are on the same page, you might be able to do something like this

frame 1
Code:
<FORM name="testForm" METHOD=GET ACTION=<?php echo $PHP_SELF?>> 
<?php 

$i = $_GET["temp"]; 

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

echo $i; 

?> 

<INPUT TYPE=SUBMIT NAME="full" VALUE="GO"> 
<INPUT TYPE=HIDDEN NAME="temp" VALUE="<?php echo $i?>"> 
<script language="javascript">
  parent.frame2.testForm.temp.value = <? echo $i ?>;
</script>
</form>
Frame two would jsut simply be
Code:
<FORM target="frame1" name="testForm" METHOD=GET ACTION=frame1.php> 
<INPUT TYPE=SUBMIT NAME="full" VALUE="GO"> 
<INPUT TYPE=HIDDEN NAME="temp" VALUE=""> 
</form>
So when frame1 loads, it updates the form value on frame2 with the value of i
then frame2 submits i back to frame1, and the cycle starts again.

Last edited by psyon; 12-14-03 at 01:02 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Plz Help! Drop Down selection opens 2 frames ppt JavaScript 3 03-27-04 12:54 PM
php and javascript together? gamextremer2003 PHP 5 11-06-03 03:18 PM
Forcing a JavaScript to abort HiMyNameIs JavaScript 3 09-18-03 11:23 AM
PLZ HLP! Sending Javascript between two frames. Caleb JavaScript 1 09-01-03 01:20 AM


All times are GMT -5. The time now is 09:49 PM.
vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.