I am using the following code to change button when it is clicked by echoing the javascript's document.getElemenById
property but the button remains as it is:
while($result=mysql_fetch_array($result1))
{
$i=1;
echo "
<tr>
<form action='student.php' method='post'>
<td>$result[0]<input type=\"hidden\" name=\"company\" value=\"$result[0]\"></td>
<td>
<input type=\"checkbox\" name=\"yes\" />
<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?');\">
<input type=\"hidden\" name=\"apply$i\" value=\"apply$i\">
</td>
</form>
</tr>
<tr><td><input type=\"text\" id=\"ankur\"></td></tr>
";
$i++;
}
echo "</table></center>";
Here the button with the id apply$i
should change to Applied
string as per the following 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 "<script language='javascript' type='text/javascript'>document.getElementById('apply1').innerHTML ='Applied';</script>"
Does anybody know the reason?Plz help