当我设置按钮类型以提交时,我似乎无法显示表单,但当按钮是按钮时,我无法取出表单。我必须使代码与按钮类型按钮一起使用。
<script type ="text/javascript">
function submitData() {
var input = document.getElementById('objectname').value;
document.getElementById("nameerror").innerHTML = "";
if (input === "") {
document.getElementById("nameerror").innerHTML = "<span style='color:red'> You need to enter the object field</span>";
}
var option1 = document.getElementById('metal');
var option2 = document.getElementById('wood');
var option3 = document.getElementById('liquid');
var option4 = document.getElementById('plant');
var option5 = document.getElementById('animal');
var option6 = document.getElementById('human');
var option7 = document.getElementById('others');
document.getElementById("optionerror").innerHTML = "";
if (option1.checked === false && option2.checked === false && option3.checked === false && option4.checked === false
&& option5.checked === false && option6.checked === false && option7.checked === false) {
document.getElementById("optionerror").innerHTML = "<span style='color:red'> You need to select an object type</span>";
}
if (!(input === "") && (!(option1.checked === false) || !(option2.checked === false))) {
document.getElementById('myform').submit();
}
}
</script>
</head>
我必须将数据传输到 server.php。当我设置要提交的按钮类型时,我可以显示此表单。但是当我将按钮类型设置为按钮时,我无法让它出现。
慕森卡
三国纷争