PHP 使用 Java 更改内部跨度 ID Html
PHP Change Span Id Inner Html using Java
我正在尝试从 php echo
statement.For 中更改跨度 ID 内部 html 文本,这是我在下面的代码中编写的,但它在 document.getElementById
中给出了句法错误行
if ($con->query("SELECT question_id FROM saved_questions WHERE question_id='".$quiz_question['id']."' and user_id='".$this->session->userdata('user_id')."'")->num_rows > 0)
{
echo ('
<SCRIPT LANGUAGE="JavaScript">
document.getElementById("btn-save'".$quiz_question['id']."'").innerHTML="newtext"; //syntex error in this line
</SCRIPT>');
}
怎么了
我建议您删除 echo
并使用普通输出:
if ($con->query("SELECT question_id FROM saved_questions WHERE question_id='".$quiz_question['id']."' and user_id='".$this->session->userdata('user_id')."'")->num_rows > 0)
{?>
<SCRIPT LANGUAGE="JavaScript">
document.getElementById("btn-save<?php echo $quiz_question['id']?>").innerHTML="newtext";
</SCRIPT>
<?php
}
我正在尝试从 php echo
statement.For 中更改跨度 ID 内部 html 文本,这是我在下面的代码中编写的,但它在 document.getElementById
中给出了句法错误行
if ($con->query("SELECT question_id FROM saved_questions WHERE question_id='".$quiz_question['id']."' and user_id='".$this->session->userdata('user_id')."'")->num_rows > 0)
{
echo ('
<SCRIPT LANGUAGE="JavaScript">
document.getElementById("btn-save'".$quiz_question['id']."'").innerHTML="newtext"; //syntex error in this line
</SCRIPT>');
}
怎么了
我建议您删除 echo
并使用普通输出:
if ($con->query("SELECT question_id FROM saved_questions WHERE question_id='".$quiz_question['id']."' and user_id='".$this->session->userdata('user_id')."'")->num_rows > 0)
{?>
<SCRIPT LANGUAGE="JavaScript">
document.getElementById("btn-save<?php echo $quiz_question['id']?>").innerHTML="newtext";
</SCRIPT>
<?php
}