...

View Full Version : need help with script



julious_dean
06-01-2006, 06:23 PM
Hi all i have a menu editor with checkboxes to choose menu item to edit. then

if (action=="unpublish") {
boxes = document.menuItems.menu_item.length
txt = ""
for (i = 0; i < boxes; i++) {
if (document.menuItems.menu_item[i].checked) {
txt = txt + document.menuItems.menu_item[i].value + " "
}
}


if (txt == "") {
alert("Please select item to unpublish.");
return ;


} else
document.menuItems.task.value=action ;
document.menuItems.submit();

}

but if there is only one menu item in list it just alerts and fails.

Any help?

vwphillips
06-01-2006, 08:36 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>
<title></title>
</head>

<body>
<script language="JavaScript" type="text/javascript">
<!--
function Ck(){
var boxes = document.menuItems.menu_item;
var txt = ""
if (!boxes.length){
if (document.menuItems.menu_item.checked) {
txt+=document.menuItems.menu_item.value;
}
}
else {
for (var i = 0; i < boxes.length; i++) {
if (document.menuItems.menu_item[i].checked) {
txt += document.menuItems.menu_item[i].value;
}
}
}
if (txt=="") {
alert("Please select item to unpublish.");
return ;
}
else {
// document.menuItems.task.value=action ;
// document.menuItems.submit();
}
}

//-->
</script>

<form name="menuItems" >
<input type="checkbox" value="fred" name="menu_item">

<input type="button" value="Check" onclick="Ck();">
</form>
</body>

</html>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum