Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-05-2006, 12:32 AM   PM User | #1
dooballoh
New Coder

 
Join Date: Jan 2006
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
dooballoh is an unknown quantity at this point
External JavaScript and PHP

Hello.

I am using phpBB and wanted to display latest poll in phpBB to my home page.
My home page is html extention and want to use java to call it and display it.

I am stuck with these codes;
php codes;
Code:
<? php
SOME, SOME....
{
echo "document.write('$poll['options'][$i]['vote_option_text']');";
} ?>
My question is that, if ['options'] then will not print anything, if I remove ' ' then print something. However if I put all 4 items ('$poll['options'][$i]['vote_option_text']');"; without ' ' inside of [ ] it will print like;
Quote:
Array[0][vote_option_text]Array[1][vote_option_text]Array[2][vote_option_text]Array[3][vote_option_text]Array[4][vote_option_text]Array[5][vote_option_text]
What is correct syntax?
Please help!!!

Thank you in advance
dooballoh is offline   Reply With Quote
Old 05-05-2006, 06:45 AM   PM User | #2
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,455
Thanks: 0
Thanked 498 Times in 490 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
If the PHP is in an external Javascript file you need to specify the scipt tag as

<script type="text/javascript" src="myfile.php"></script>

so that it gets parsed as PHP on the server first before being run as Javascript by the browser.
__________________
Stephen
Learn Modern JavaScript - http://javascriptexample.net/
Helping others to solve their computer problem at http://www.felgall.com/
felgall is offline   Reply With Quote
Old 05-06-2006, 01:50 AM   PM User | #3
dooballoh
New Coder

 
Join Date: Jan 2006
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
dooballoh is an unknown quantity at this point
Ooops, I may be in wrong forum.

Thank you very much 'felgall'.

I may didn't make it clear.
I've already did that part in my html page.
Also I changed my php file as below;
Code:
<?php 
Header("content-type: application/x-javascript"); 

function myfunction() 
{ 
return $something; 
} 

$some_variable=$something; 

echo "document.write('$poll['options'][$i]['vote_option_text']');";

?>
When called remotely by javaScript, I included this in my html page as below;
Code:
<script> type="text/javascript" src="http://www.mydomain.com/myfile.php"></script>
But then problem is as my first post.
Help please.

Thank you in advance
dooballoh is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:34 PM.


Advertisement
Log in to turn off these ads.