I have two scripts which work on the same form:
Script one combines the results of two radio buttons to create a combined menu:
<!-- Begin
site="function combineMenus(frm, menu1, menu2) {
with (frm) {
for (var i = 0; i < document.menufrm.menu1.length; i++) {
if (document.menufrm.menu1.checked) {
str = document.menufrm.menu1.value;
break;
}
}
for (var i = 0; i < document.menufrm.menu2.length; i++) {
if (document.menufrm.menu2.checked) {
str += document.menufrm.menu2.value;
break;
}
}
url = site + "/" + str + ".html";
window.location.href = url;
}
}
// End -->
The second script is to validate the menus:
<!-- Begin
function checkRadios() {
var el = document.forms[0].elements;
for(var i = 0 ; i < el.length ; ++i) {
if(el.type == "radio") {
var radiogroup = el[el.name]; // get the whole set of radio buttons.
var itemchecked = false;
for(var j = 0 ; j < radiogroup.length ; ++j) {
if(radiogroup[j].checked) {
itemchecked = true;
break;
}
}
if(!itemchecked) {
alert("Please choose an answer for "+el.name+".");
if(el.focus)
el.focus();
return false;
}
}
}
return true;
}
// End -->
Can anyone advise on a way to combine this scripts into one fully working script?
many thanks
Script one combines the results of two radio buttons to create a combined menu:
<!-- Begin
site="function combineMenus(frm, menu1, menu2) {
with (frm) {
for (var i = 0; i < document.menufrm.menu1.length; i++) {
if (document.menufrm.menu1.checked) {
str = document.menufrm.menu1.value;
break;
}
}
for (var i = 0; i < document.menufrm.menu2.length; i++) {
if (document.menufrm.menu2.checked) {
str += document.menufrm.menu2.value;
break;
}
}
url = site + "/" + str + ".html";
window.location.href = url;
}
}
// End -->
The second script is to validate the menus:
<!-- Begin
function checkRadios() {
var el = document.forms[0].elements;
for(var i = 0 ; i < el.length ; ++i) {
if(el.type == "radio") {
var radiogroup = el[el.name]; // get the whole set of radio buttons.
var itemchecked = false;
for(var j = 0 ; j < radiogroup.length ; ++j) {
if(radiogroup[j].checked) {
itemchecked = true;
break;
}
}
if(!itemchecked) {
alert("Please choose an answer for "+el.name+".");
if(el.focus)
el.focus();
return false;
}
}
}
return true;
}
// End -->
Can anyone advise on a way to combine this scripts into one fully working script?
many thanks