我使用下面的代碼時,它是由呼應JavaScript的document.getElemenById
財產點擊,但按鍵仍然是它是改變按鈕:呼應JavaScript的PHP內
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>";
這裏與ID按鈕apply$i
應該改變到Applied
字符串按下面的代碼
$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>"
是否有人知道原因嗎?plz幫助
我猜你有多個id設置爲'apply1'的項目。爲什麼每次都在循環內設置$ i爲1? – Tony 2013-05-02 18:16:11