By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,751 Members | 1,156 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,751 IT Pros & Developers. It's quick & easy.

how to use php variable in .js file

P: 1
plz help

I have a php variable $content on page menu.php
now i wnt to use its value on page menu_items.js

hear menu_items.js create a menubar.its contan both static and dynamic menu

my lase menu as vander is dynamic now how can i use this variable on .js

my js file look like

['OUTDOOR LIVING', 'http://www.designresourcestlouis.com/outdoorliving/index.php', null,
['Landscaping', 'http://www.designresourcestlouis.com/outdoorliving/landscaping.php'],
['Pool & Fence', 'http://www.designresourcestlouis.com/outdoorliving/poolfence.php'],
['Hot Tubs', 'http://www.designresourcestlouis.com/outdoorliving/hottubs.php'],
['Decks & Patios', 'http://www.designresourcestlouis.com/outdoorliving/deckspatios.php'],
['Outdoor Furniture', 'http://www.designresourcestlouis.com/outdoorliving/furniture.php'],
['Kitchens & Living Spaces', 'http://www.designresourcestlouis.com/outdoorliving/kitchensliving.php'],
['Sunrooms & Porches', 'http://www.designresourcestlouis.com/outdoorliving/sunrooms.php']
],
['VENDORS', 'http://www.designresourcestlouis.com/vendors/category.php', null,

in this space i want my variable value
],

my variable contain value
['1', '../subcategory.php?id=14', null,['111', '../listing.php?id=1', null,],['13', '../listing.php?id=3', null,],['14', '../listing.php?id=4', null,],['fegvrbt5 bh', '../listing.php?id=5', null,],],['2', '../subcategory.php?id=15', null,['111', '../listing.php?id=1', null,],['14', '../listing.php?id=4', null,],],['3', '../subcategory.php?id=16', null,['111', '../listing.php?id=1', null,],['12', '../listing.php?id=2', null,],['13', '../listing.php?id=3', null,],['14', '../listing.php?id=4', null,],],['aa', '../subcategory.php?id=17', null,[';..,/,Ltytryrty', '../listing.php?id=6', null,],],['ankur', '../subcategory.php?id=18', null,['fegvrbt5 bh', '../listing.php?id=5', null,],],['test', '../subcategory.php?id=20', null,[';..,/,Ltytryrty', '../listing.php?id=6', null,],],['tgrhth', '../subcategory.php?id=19', null,['111', '../listing.php?id=1', null,],],
May 9 '07 #1
Share this Question
Share on Google+
1 Reply


Motoma
Expert 2.5K+
P: 3,235
You can do this by having your .js file be a .php file instead. Then when you include it, you can drop your PHP variables in and everything should work fine.
May 9 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.