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

import php variable to javascript

P: 1
hi all

i am new to web programming and m stuck at one point. i want to import a php variable to javascript and later want to display it in a text box which should be triggered by "onclick" event by a submit button..plsss help!!
Apr 18 '12 #1
Share this Question
Share on Google+
1 Reply

P: 1,059
this is the most simple problem;
here is an example solution;

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $to_disp="excel";
  3. ?>
  4. <script>
  5. var to_disp='<?php echo $to_disp?>';
  6. </script>
in cases you would also need to use addslashes, but i didnt show it, you find it out
Apr 18 '12 #2

Post your reply

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