Member Avatar for kings
<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>

i want to alert the variable using onclick function.

Member Avatar for nav33n

Umm.. you are passing the id as a parameter. Why are you trying to assign the value of $id to t (in javascript function) ?

<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>

This works just fine !

commented: Another great snippet+7
Member Avatar for kings

thank u.it's working.....

Member Avatar for nav33n

:) You are welcome!

Member Avatar for bwls

How would you do this without a button?

Thanks.

Bill

Member Avatar for vkey

very nice yar. thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.