I am trying to combine two scripts on the same menu:
This one to combine two radio buttons as a menu
[CODE]<!– Begin
site=”http://javascript.internet.com”;
function combineMenus(frm, menu1, menu2) {
with (frm) {
for (var i = 0; i < document.menufrm.menu1.length; i++) {
if (document.menufrm.menu1[i].checked) {
str = document.menufrm.menu1[i].value;
break;
}
}
for (var i = 0; i < document.menufrm.menu2.length; i++) {
if (document.menufrm.menu2[i].checked) {
str += document.menufrm.menu2[i].value;
break;
}
}
url = site + “/” + str + “.html”;
window.location.href = url;
}
}
// End –>
And this one to validate the radio buttons
[CODE]<!– Begin
function checkRadios() {
var el = document.forms[0].elements;
for(var i = 0 ; i < el.length ; ++i) {
if(el[i].type == “radio”) {
var radiogroup = el[el[i].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[i].name+”.”);
if(el[i].focus)
el[i].focus();
return false;
}
}
}
return true;
}
// End –>
Well these two don’t work together, as script 2 does not stop script 1 so script 1 reports javascript errors.
Is there anyway I can get these two scripts to work, without having to use any php or asp in my form (cos I don’t have a clue what I am doing there).
Thanks