我的表单中有一个隐藏字段。在提交表单时,我调用数据库函数将输入添加到数据库并返回查询结果。我希望将值设置为返回隐藏字段。但是当我不能给它赋值时
<form name="frmAddBook" id="frmAddBook" method="post">
<input type="hidden" name="actionResult" id="actionResult">
的PHP
echo '
<script type="text/javascript">
alert("hello");
document.getElementById("actionResult").value=1;
alert("2222222");
alert(document.frmAddBook.getElementById("actionResult").value);
</script>';
参考方案
您需要指定该隐藏输入字段的值,因此,如果要在PHP中执行此操作,则应如下所示:
<input type="hidden" name="actionResult" id="actionResult" value="<?php echo $result; ?>"/>
PHP:获取调用引用的数组名称 - php假定以下函数并调用:function doSomething( &$someArray ) { // Do something to $someArray } $names=array("John", "Paul", "George", "Ringo"); doSomet…
PHP-MySQL结果转换为JSON - php我试图了解如何将MySQL结果转换为JSON格式,以便以后可以在Javascript中使用此JSON来构建HTML表。但是我的代码只是产生大量的空值,我还不明白为什么。$result = mysqli_query($con, "SELECT * FROM Customers"); $test = json_encode($result);…
PHP Count数组元素 - php嗨,有人可以解释为什么这会返回“数组由0个元素组成”。 :$arr = array(1,3,5); $count = count($arr); if ($count = 0) { echo "An array is empty."; } else { echo "An array has $count elements.…
PHP:从函数返回值并直接回显它? - php这可能是一个愚蠢的问题,但是……的PHPfunction get_info() { $something = "test"; return $something; } html<div class="test"><?php echo get_info(); ?></div> 有没有办…
PHP:将数据从二维数组复制到一维数组的最快方法 - php我有一个巨大的二维PHP数组,带有500万行。$t = [ [ "id" => 1, "name" => "foo" ], [ "id" => 2, "name" => "bar" ] ]; 现在,我必须将此数组的I…