By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,726 Members | 1,189 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,726 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', '', null,
['Landscaping', ''],
['Pool & Fence', ''],
['Hot Tubs', ''],
['Decks & Patios', ''],
['Outdoor Furniture', ''],
['Kitchens & Living Spaces', ''],
['Sunrooms & Porches', '']
['VENDORS', '', 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

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.