我正在处理提交给要转换为文本文件的服务器的表单视图。视力需要将数据发布到服务器端的php。还需要在URL中添加“?PART_NO = 部分 & frm = MF001”以命名每个文本文件。
如果表单包含多个单选按钮,它会使JavaScript崩溃。这可能是因为我试图访问表单元素的方式。我只需要访问名称为“Part_No”的文本字段。HTML单选按钮崩溃JavaScript表单功能
<!DOCTYPE html>
<html>
<body>
<form id="test" method="post" action="http://10.0.0.252/test.php" onsubmit="process()">
<input type="checkbox" tabindex="40" id="form67_1" data-objref="458 0 R" name="box_brown" imageName="1/form/416 0 R" images="110100"/>
<input type="radio" tabindex="32" id="form68_1" data-objref="495 0 R" name="rc-50" value="yes" imageName="1/form/497 0 R" images="110100" checked="checked"/>
<input type="radio" tabindex="31" id="form69_1" data-objref="494 0 R" name="a2262at" value="no" imageName="1/form/494 0 R" images="110100"/>
<input type="radio" tabindex="17" id="form70_1" data-objref="509 0 R" name="process" value="no" imageName="1/form/509 0 R" images="110100"/>
<input type="radio" tabindex="11" id="form71_1" data-objref="503 0 R" name="master_glass" value="no" imageName="1/form/503 0 R" images="110100"/>
<input type="text" tabindex="4" id="form129_1" value="2" data-objref="62 0 R" title="Part No." name="Part_No"/>
<input type="submit" value="Submit">
</form>
<script>
function process() {
var form = document.getElementById('test');
var elements = form.elements["Part_No"];
var values = [];
values.push(encodeURIComponent(elements.name) + '=' + encodeURIComponent(elements.value) + "&frnm=MF001");
form.action += '?' + values;
}
</script>
</body>
</html>
这里的服务器端脚本,如果有人有兴趣。
<?php
$name = $_GET['Part_No'];
$nom = $_GET['frnm'];
ob_start();
$file = $GLOBALS['HTTP_RAW_POST_DATA'];
$time = microtime(true);
$newfile = "./customers/" . $nom . "." . $name . "." . $time . ".txt";
$worked = file_put_contents($newfile, $file);
ob_end_clean();
exit();
?>
没有ID为“”Part_No“的_text字段_ ... –
”“对不起,我的意思是姓名 –