Why does the click not respond?

<?php
$str1="Hello";
$str2="start PHP";
echo "<script>";
echo "alert("".$str1."");";
echo "</script>";

?>

<input type="text" name="tx" size="20" value="<?php echo $str1;?>">
<input type="button" value="click" onclick="tx.value="<?php echo $str2;?>"">



ok

Why does not start PHP? appear when clicking click,

Php
Apr.03,2021

tx is not defined

change onclik to:

onclick="var tx = document.getElementsByTagName('input')[0];tx.value='<?php echo $str2;?>'"

Not even F12?

clipboard.png


Brother, your tx is not defined, and the browser doesn't know who tx is. If you want it to do something, you have to tell it who tx is. Change it, for example:

<input type="button" value="click" onclick="document.getElementsByName('tx')[0].value=''">
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e9c50f-18c9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e9c50f-18c9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?