function confirmappt(target) {
var type = document.getElementById("ultrasoundid").value
var ultrasound = document.getElementById("hdultrasoundid").value
var appt = document.getElementById('apptdocfacid').value
appt = 'apptid' + appt + '_1'
var checkedValue = 'test'
for (var i = 0; i < 100; i++) {
if (document.getElementsByName(appt)[i].checked) {
checkedValue = 'ok'
break;
}
}
if (checkedValue == 'ok') {
alert('Please select ultrasound type!');
}
if (confirm('Are you sure you want to make this appointment?'))
return true;
return false;
}
如果checkedValue相等,则在条件正常的情况下,警报和秒都可以。但是checkedValue不等于确定,然后如果条件不起作用则秒。请帮我解决这个问题。
最佳答案
您需要添加else
块
我觉得你需要
if (checkedValue == 'ok') {
alert('Please select ultrasound type!');
}else{
return confirm('Are you sure you want to make this appointment?');
}