| | |
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 |
# 5.2.10 access action address alexa apache api array auto autoincrement broken cakephp checkbox class classes clean clients cms code cron curl database date dehasher destroy directory dissertation domain dropdown dynamic echo$_get[x]changingitintovariable... email encode error errorlog fairness fatalerror file folder form function functions google href htaccess html image include indentedsubcategory ip javascript joomla legislation limit link load local login masterthesis memberships menu multiple multipletables mysql mysqlquery newsletters oop open passwords paypal pdf persist php popup provider query radio random script search secure server sessions simple sockets source space spam sql system table tutorial upload url user variable voteup web youtube







You are welcome!