【发布时间】:2016-08-11 22:52:22
【问题描述】:
嘿,伙计们,为什么不工作?当我单击按钮时,然后将文本重写为下一个数组元素。 这个:
<button onclick="elfogadas()" id="elfog">Elfogadom</button>
功能:
function elfogadas() {';
echo '$("#ititle").html("' . $idea_title[$random_values[$vid]] . '");
}
</script>';
用 PHP 编码 数组元素没问题 但只有 1x 编辑文本。
这是为什么?
希望能帮到你。
(抱歉英语不好)
更新:
声明的 random_values 数组
$random_values = array();
for($i = 0; $i <= $all_ideas-1; $i++){
$random = rand(1, $all_ideas);
while(in_array($random, $random_values)) $random = rand(1, $all_ideas);
$random_values[] = $random;
}
抢先
echo '<center><h4 id="ititle" style="color: white;">' . $idea_title[$random_values[$vid]] . '</h4>
<hr style="border: 1px solid white;">
<font id="istyle" style="color: white;">' . $idea_style[$random_values[$vid]] . '</font><br>
<textarea id="itext" style="height: 300px; width: 410px;" name="bbcode_field">' . $idea_text[$random_values[$vid]] . '</textarea><br>
<font id="icreatedb" style="color: white;">Ötlet kitalálója: ' . $idea_created[$random_values[$vid]] . '</font><br>
<table width="100%" style="margin-top: 25px; margin-bottom: 25px;"><tr width="100%"><center>
<td width="50%"><center><button onclick="elfogadas()">Elfogadom</button></center></td>
<td width="50%"><center><button onclick="elutasit()">Elutasítom</button></center></td></center>
</tr>
</table>
</center>';
使用 onclick 功能编辑使用
$conn->close();
?>
<script>
function elfogadas() {
<?php $vid++; ?>
$("#ititle").html("<?php echo $idea_title[$random_values[$vid]]; ?>");
return 1;
}
</script>
我的问题只是一次编辑以下项目不显示。 对不起对不起英语不好。
【问题讨论】:
-
javascript onclick 只能调用 javascript 函数,不能调用 php 函数。要调用 php 函数,您必须对 php 页面进行 ajax 调用,并且要么使该页面始终调用该函数,要么发送一些参数并使用 if-logic 来确定要调用的 php 函数
-
echo在JavaScript函数中?
标签: javascript php jquery arrays