Note that there are some explanatory texts on larger screens.

plurals
  1. POecho JavaScript inside PHP
    primarykey
    data
    text
    <p>I am using the following code to change button when it is clicked by echoing the javascript's <code>document.getElemenById</code> property but the button remains as it is:</p> <pre><code>while($result=mysql_fetch_array($result1)) { $i=1; echo " &lt;tr&gt; &lt;form action='student.php' method='post'&gt; &lt;td&gt;$result[0]&lt;input type=\"hidden\" name=\"company\" value=\"$result[0]\"&gt;&lt;/td&gt; &lt;td&gt; &lt;input type=\"checkbox\" name=\"yes\" /&gt; &lt;input type=\"submit\" name=\"apply$i\" id=\"apply$i\" class=\"buttons\" style=\"border: none\" value=\"Apply now!\" onclick=\"return confirm('Are You Sure you want to apply?');\"&gt; &lt;input type=\"hidden\" name=\"apply$i\" value=\"apply$i\"&gt; &lt;/td&gt; &lt;/form&gt; &lt;/tr&gt; &lt;tr&gt;&lt;td&gt;&lt;input type=\"text\" id=\"ankur\"&gt;&lt;/td&gt;&lt;/tr&gt; "; $i++; } echo "&lt;/table&gt;&lt;/center&gt;"; </code></pre> <p>Here the button with the id <code>apply$i</code> should change to <code>Applied</code> string as per the following code</p> <pre><code>$id=$_SESSION['sessionid']; if(isset($_POST['apply1'])) { if(isset($_POST['yes'])) { $yes=trim(mysql_prep($_POST['yes'])); $company=trim(mysql_prep($_POST['company'])); $button_id=trim(mysql_prep($_POST['apply1'])); if($yes=="on") { $query ="select `Branch`,`Class` from `student_details` where `Userid`='$id'"; $temp1= mysql_query($query); $temp2= mysql_fetch_array($temp1); $query="insert into `student_applied` values ('$id' ,'$temp2[0]' ,'$temp2[1]' ,'$company')"; //$query="UPDATE `student`.`users` SET `Activated` = '1' WHERE `users`.`Userid` = '$student'"; $result = mysql_query($query); confirm_query($result); if($result) { echo "ok"; echo "&lt;script language='javascript' type='text/javascript'&gt;document.getElementById('apply1').innerHTML ='Applied';&lt;/script&gt;" </code></pre> <p>Does anybody know the reason?Plz help</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload