Go Back   CodingForums.com > :: Client side development > JavaScript programming

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 03-19-2009, 08:19 PM   PM User | #1
levani
Regular Coder

 
levani's Avatar
 
Join Date: Mar 2009
Location: Georgia
Posts: 183
Thanks: 29
Thanked 1 Time in 1 Post
levani is an unknown quantity at this point
PHP code in javascript

Hi

I have a popup script written in javascript and I want to add some php code there.

This is the beginning of the code:

Quote:
var defaultMenuWidth="150px" //set default menu width.

var linkset=new Array()
//SPECIFY MENU SETS AND THEIR LINKS. FOLLOW SYNTAX LAID OUT

linkset[0]='<a href="http://dynamicdrive.com">Dynamic Drive</a>'
linkset[0]+='<hr>' //Optional Separator
linkset[0]+='<a href="http://www.javascriptkit.com">JavaScript Kit</a>'
linkset[0]+='<a href="http://www.codingforums.com">Coding Forums</a>'
linkset[0]+='<a href="http://www.cssdrive.com">CSS Drive</a>'
linkset[0]+='<a href="http://freewarejava.com">Freewarejava</a>'

linkset[1]='<?php echo "Something"; ?>'
linkset[1]+='<a href="http://cnn.com">CNN</a>'
linkset[1]+='<a href="http://news.bbc.co.uk">BBC News</a>'
linkset[1]+='<a href="http://www.washingtonpost.com">Washington Post</a>'
How can I modify this script to make the php work properly?

See this link for whole code and more info:
http://www.dynamicdrive.com/dynamicindex1/popit.htm


Thanks in advance
levani is offline   Reply With Quote
Old 03-19-2009, 08:30 PM   PM User | #2
Eldarrion
Regular Coder

 
Join Date: Feb 2009
Location: Wheeling, IL
Posts: 358
Thanks: 5
Thanked 62 Times in 60 Posts
Eldarrion is on a distinguished road
Exactly what is not working with it? Is the file's extension 'php'? Is the server you're running it on enabled to use PHP to begin with or are you testing it locally without a server running?
__________________
The way to success is to assume that there are no impossible things. After all, if you think something is impossible, you will not even try to do it.

How to ask smart questions?
Eldarrion is offline   Reply With Quote
Users who have thanked Eldarrion for this post:
levani (03-19-2009)
Old 03-19-2009, 08:31 PM   PM User | #3
ohgod
Regular Coder

 
ohgod's Avatar
 
Join Date: Jun 2008
Location: Ohio
Posts: 579
Thanks: 6
Thanked 69 Times in 69 Posts
ohgod is on a distinguished road
where is YOUR code? what's not working?

that should work fine if it's a php page and that echo gets processed as the page is being built.
ohgod is offline   Reply With Quote
Users who have thanked ohgod for this post:
levani (03-19-2009)
Old 03-19-2009, 08:47 PM   PM User | #4
levani
Regular Coder

 
levani's Avatar
 
Join Date: Mar 2009
Location: Georgia
Posts: 183
Thanks: 29
Thanked 1 Time in 1 Post
levani is an unknown quantity at this point
Well, the extension was .js and I changed it to php. Now everything seems to work fine

Will all php code work properly as in standard php file?
levani is offline   Reply With Quote
Old 03-19-2009, 08:49 PM   PM User | #5
Eldarrion
Regular Coder

 
Join Date: Feb 2009
Location: Wheeling, IL
Posts: 358
Thanks: 5
Thanked 62 Times in 60 Posts
Eldarrion is on a distinguished road
Don't see why it shouldn't. <?php ?> inside <script> tags is interpreted fine provided the server knows to look for it and supports it.
__________________
The way to success is to assume that there are no impossible things. After all, if you think something is impossible, you will not even try to do it.

How to ask smart questions?
Eldarrion is offline   Reply With Quote
Users who have thanked Eldarrion for this post:
levani (03-19-2009)
Old 03-19-2009, 08:54 PM   PM User | #6
levani
Regular Coder

 
levani's Avatar
 
Join Date: Mar 2009
Location: Georgia
Posts: 183
Thanks: 29
Thanked 1 Time in 1 Post
levani is an unknown quantity at this point
OK, thank you very very much.

Great forum!!!
levani 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 02:11 AM.


Advertisement
Log in to turn off these ads.