Jump to content

Passing PHP variables through Javascript?


spires

Recommended Posts

Hi

 

I know this is a javascript based question, but as its passing

PHP the javascript guys don't seem to know to do it.

 

Can ou help.

 

I'm having trouble passing PHP

varables from outside the Iframe to inside the Iframe.

 

this is what i'm trying at the moment:

main page

<iframe src="listings_text.php?time_frame=this" NAME="ishort" width="385" height="290"> </iframe>

 

 

I was thinking it would be something like this, but this is not working.

<?php
$time_frame = 'this';
?>
<iframe src="<?php echo 'listings_text.php?time_frame='.$time_frame.''; ?>" NAME="ishort" width="385" height="290"> </iframe>

 

 

This is the page that the Iframe links to, This is where i'm trying to get the variable.

<?php
$time_frame = $_GET['time_frame'];
echo $time_frame;
?>

 

 

I hope this makes sence,

Thank you for helping.

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/52725-passing-php-variables-through-javascript/
Share on other sites

Have you viewed the source to make sure that the echo is printing everything it should be, and have you also checked that iframe's allow this type of url to be passed with GET data? Have you also checked that the listings_text.php is in the same directory and does not require the first initial http:// part.

 

Try it with the full url in the SRC, http:// and all. see what happends.

HI

 

Thanks for replying,

I just tried the full URL but its still going through.

 

I'm not to sure if Iframes will pass GET variable in this way,

But, i'm not to sure how else you would do it.

 

Here is the URL i'm working on.

http://www.telegraphlondon.co.uk/list_upload.php

 

The right Iframe should be echoing 1

 

Any more ideas would be great.

Thanks

You can do it with javascript by setting the variable you want to be passed on the page inside of a form as an input hidden type and on page load you push that variable by getting it by id to the iframe.

 

I am not a javascript guru just know the basics etc, but yea. It is possible, just not 100% clear on how to do it.

Archived

This topic is now archived and is closed to further replies.

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