bulz Posted April 4, 2012 Share Posted April 4, 2012 Hi, I'm a newbie in web developer. I'd like to use someone's JS function, but i don't know it doesn't work after i combine with my code. I give an example of my code, even though it's not the real code. The main problem is I want to give value in the textarea, when user click the button. But the value is from some php processes (in this example i choose to use a variable $num=5 as the final result of php processes) <html> <head> <script type="text/javascript"> function displayResult(a) { document.getElementById("myTextarea").value= a; } </script> </head> <body> <textarea id="myTextarea" cols="20"> </textarea> <br /> <?php $num=5;?> <button type="button" onclick="displayResult(<?=$num;?>)">Alert value of text area</button> </body> </html> Please help me :'( Thanks before Link to comment https://forums.phpfreaks.com/topic/260315-passing-value-cant-work/ Share on other sites More sharing options...
sunfighter Posted April 4, 2012 Share Posted April 4, 2012 Change this line to this: <button type="button" onclick="displayResult(<?php echo $num; ?>)">Alert value of text area</button> Link to comment https://forums.phpfreaks.com/topic/260315-passing-value-cant-work/#findComment-1334376 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.