Javascript 无法显示php到html输入表单的值
我想在html上显示数组值。数组值来自php 选择选项正在工作,但下一个字符串值不显示 就像这张照片 (这不起“获取价值”的作用。我认为……) 源代码在这里 PHP-Javascript 无法显示php到html输入表单的值,javascript,php,jquery,html,arrays,Javascript,Php,Jquery,Html,Arrays,我想在html上显示数组值。数组值来自php 选择选项正在工作,但下一个字符串值不显示 就像这张照片 (这不起“获取价值”的作用。我认为……) 源代码在这里 PHP- <?php $arr[0]="11.1.35.132"; ?> <html> <head> <link rel="stylesheet" type="text/css" href="../css/main.css"> <script type="text/ja
<?php
$arr[0]="11.1.35.132";
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="../css/main.css">
<script type="text/javascript">
function getR() {
document.forms['save']['cnt_mme'].value = "<?php echo count($arr); ?>";
document.forms['save']['mmeremoteip'].value = <?php echo json_encode($arr[0]); ?>;
}
</script>
</head>
<body onLoad="getR();">
<form name="save" method="post">
<h1>TEST</h1>
<table>
<tr><td>No. of IP</td>
<td id="cnt_mme">
<script>
var mmeip = "<?php echo count($arr); ?>";
var opt = document.getElementById("cnt_mme");
var html="<select size=\"1\"";
for(i = 0; i < mmeip; i++) {
html += "<option value=\"" + i + "\">" + i +"</option>";
}
html + "</select></td>";
opt.innerHTML = html;
</script>
<tr>
<td class="param">Remote IP</td>
<td><input type="text" class="inputParam" size="20" maxlength="15" name="mmeremoteip" id="MME REMOTE IP"></td>
</tr>
</tr>
</table>
</body>
</html>
php代码有。。只有数组值。并且该值将发布到HTML
HTML-
<?php
$arr[0]="11.1.35.132";
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="../css/main.css">
<script type="text/javascript">
function getR() {
document.forms['save']['cnt_mme'].value = "<?php echo count($arr); ?>";
document.forms['save']['mmeremoteip'].value = <?php echo json_encode($arr[0]); ?>;
}
</script>
</head>
<body onLoad="getR();">
<form name="save" method="post">
<h1>TEST</h1>
<table>
<tr><td>No. of IP</td>
<td id="cnt_mme">
<script>
var mmeip = "<?php echo count($arr); ?>";
var opt = document.getElementById("cnt_mme");
var html="<select size=\"1\"";
for(i = 0; i < mmeip; i++) {
html += "<option value=\"" + i + "\">" + i +"</option>";
}
html + "</select></td>";
opt.innerHTML = html;
</script>
<tr>
<td class="param">Remote IP</td>
<td><input type="text" class="inputParam" size="20" maxlength="15" name="mmeremoteip" id="MME REMOTE IP"></td>
</tr>
</tr>
</table>
</body>
</html>
函数getR(){
document.forms['save']['cnt_mme'].value=“”;
document.forms['save']['mmemoteip'].value=;
}
试验
知识产权数目
var mmeip=“”;
var opt=document.getElementById(“cnt_mme”);
var html=“document.forms['save']['mmemoteip'].value=;
不需要对其进行编码。此处选择标记未关闭,并尝试在脚本中访问的数组中添加更多值
例如,添加
<?php
$arr=array();
$arr[0]="11.1.35.132";
$arr[1]="11.1.35.133";
$arr[2]="11.1.35.135";
?>
添加更改关闭html中的选择标记:
<script>
var mmeip = "<?php echo count($arr); ?>";
var opt = document.getElementById("cnt_mme");
alert(mmeip)
var html="<select size=\"1\">";
for(var i = 0; i < mmeip; i++) {
html += "<option value="+ i + ">" + i +"</option>";
}
html + "</select></td>";
opt.innerHTML = html;
</script>
var mmeip=“”;
var opt=document.getElementById(“cnt_mme”);
警报(mmeip)
var html=“”;
对于(变量i=0;i
您将获得带有0,1,2选项值的选项列表。您的关闭表单标签在哪里