我尝试使用html表单进行一次考试,这会找到错误的答案并使用警告框写出正确的答案。但我想使用另一个自定义警报框。
当我点击提交按钮时,我想打开自定义提示框。
使用此提示框http://www.abeautifulsite.net/blog/2008/12/jquery-alert-dialogs/
谢谢!!! 谢谢!!!
这是代码。
<SCRIPT Language ="JavaScript">
function ValidateForm(){
result = new Array();
count = 0;
if (!document.forms[0].one[1].checked == true) {
result[count] = "Question 1. Correct answer is " + document.forms[0].one[1].value + ".";
count++;
}
if (!document.forms[0].two[1].checked == true) {
result[count] = "Question 2. correct answer is" + document.forms[0].two[1].value + ".";
count++;
}
if (!document.forms[0].three[0].checked == true) {
result[count] = "Question 3. The correct answer is " + document.forms[0].three[0].value + ".";
count++;
}
if (!document.forms[0].four[2].checked == true) {
result[count] = "Question 4. The correct answer is " + document.forms[0].four[2].value + ".";
count++;
}
if (result.length > 0) {
var vString = "";
for (var i=0; i<result.length; i++) {
vString = vString + result[i] + "\n";
}
alert(result.length + " incorrect answer:\n" + vString);
return(false);
}
else {
alert("All of the questions were answered correctly so submit email notice.");
return(true);
}
}
</SCRIPT>
<SCRIPT Language ="JavaScript">
function ValidateForm(){
result = new Array();
count = 0;
if (!document.forms[0].one[1].checked == true) {
result[count] = "Question 1. Correct answer is " + document.forms[0].one[1].value + ".";
count++;
}
if (!document.forms[0].two[1].checked == true) {
result[count] = "Question 2. correct answer is" + document.forms[0].two[1].value + ".";
count++;
}
if (!document.forms[0].three[0].checked == true) {
result[count] = "Question 3. The correct answer is " + document.forms[0].three[0].value + ".";
count++;
}
if (!document.forms[0].four[2].checked == true) {
result[count] = "Question 4. The correct answer is " + document.forms[0].four[2].value + ".";
count++;
}
if (result.length > 0) {
var vString = "";
for (var i=0; i<result.length; i++) {
vString = vString + result[i] + "\n";
}
alert(result.length + " incorrect answer:\n" + vString);
return(false);
}
else {
alert("All of the questions were answered correctly so submit email notice.");
return(true);
}
}
</SCRIPT>