Jump to content

passing value can't work


bulz

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/260315-passing-value-cant-work/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.