我想从表中获取数据。
我不知道我的代码是否可以从我的表中获取值。
<script>
function validateForm() {
var x = document.forms["assessmentForm"]["perf_rating11"].value;
var y = document.forms["assessmentForm"]["skaneed_N11"].value;
var txt;
if (confirm((x==5||4)&&(y==1))== true){
document.write("text here");
} else {
// empty else statement.
}
}
</script>
这是我的提交代码:
<form name="assessmentForm" action="http://localhost/login/insert.php" onsubmit="return validateForm()" method="get">
数据来自如下表格:
<td><?php include 'connection_ska_c11.php';?></td>
<td style="padding:0 15px 0 15px;"><input type="radio" name="perf_rating11"
<?php if (isset($perf_rating11) && $perf_rating11=="outstanding") echo "checked";?>
value="5" required></td>
<td style="padding:0 15px 0 15px;"><input type="radio" name="perf_rating11"
<?php if (isset($perf_rating11) && $perf_rating11=="very_satisfactory") echo "checked";?>
value="4" required></td>
<td style="padding:0 15px 0 15px;"><input type="radio" name="perf_rating11"
<?php if (isset($perf_rating11) && $perf_rating11=="satisfactory") echo "checked";?>
value="3"></td>
<td style="padding:0 15px 0 15px;"><input type="radio" name="perf_rating11"
<?php if (isset($perf_rating11) && $perf_rating11=="unsatisfactory") echo "checked";?>
value="2"></td>
<td style="padding:0 15px 0 15px;"><input type="radio" name="perf_rating11"
<?php if (isset($perf_rating11) && $perf_rating11=="poor") echo "checked";?>
value="1"></td>
答案 0 :(得分:0)
而不是使用此
var y = document.forms["assessmentForm"]["skaneed_N11"].value;
我使用jquery
var y = $('.skaneed_N11:checked').val();
所以现在我的代码是
<script>
function validateForm(form){
var x = document.forms["assessmentForm"]["perf_rating11"].value;
var y = $('.skaneed_N11:checked').val();
if ((x == 5 || x == 4) && (y == 1)){
confirm("Your input values conflict, do you want to continue?");
return false;
}
}
</script>