| | |
want to pass php variable to javascript
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
PHP Syntax (Toggle Plain Text)
<html> <head> <SCRIPT LANGUAGE="JAVASCRIPT" TYPE="TEXT/JAVASCRIPT"> <!-- function login(t) { var t = '<?php echo $id; ?>'; alert(t); } --> </SCRIPT> </head> <body> <?php $id=$_GET['id']; print "<input type='button' name='button' value='button' onClick='login('$id')'>"; ?> </body> </html>
Umm.. you are passing the id as a parameter. Why are you trying to assign the value of $id to t (in javascript function) ?
This works just fine !
php Syntax (Toggle Plain Text)
<html> <head> <SCRIPT LANGUAGE="JAVASCRIPT" TYPE="TEXT/JAVASCRIPT"> <!-- function login(t) { alert(t); } --> </SCRIPT> </head> <body> <?php $id=$_GET['id']; print "<input type='button' name='button' value='button' onClick=login('$id')>"; ?> </body> </html>
Ignorance is definitely not bliss!
*PM asking for help will be ignored*
*PM asking for help will be ignored*
![]() |
Similar Threads
- Passing data from forms from one page to another (JavaScript / DHTML / AJAX)
- Send variable from javascript to php? (PHP)
- pass the value to the text box (JavaScript / DHTML / AJAX)
- Pass Javascript variable to PHP code (PHP)
- Pass a javascript variable to PHP in the same function (JavaScript / DHTML / AJAX)
- get html element value using php (PHP)
- Passing variables to and from PHP (JavaScript / DHTML / AJAX)
Other Threads in the PHP Forum
- Previous Thread: how to create-call stored procedure
- Next Thread: system("ls") okay, system("cp") not. Why?
| Thread Tools | Search this Thread |
301 ajax apache api array autosuggest beginner binary broken cakephp checkbox class cms code compression cron curl data database date display dynamic echo email error execution file files folder foreach form forms function functions google href htaccess html httppost image include insert integration ip java javascript joomla library limit link links login loop mail md5 menu mlm multiple mysql mysql_real_escape_string oop paypal pdf php problem query radio random recursion regex remote script search searchbox server session sessions sms soap sorting source space sql syntax system table tutorial update upload url validator variable video volume votedown web website xml youtube zend







You are welcome!