[code=html]<html>
<head>
<SCRIPT LANGUAGE=”JavaScript”>
function checkrights(userid) {
box0 = “document.form1.” + userid + “_right_0”;
box1 = “document.form1.” + userid + “_right_1”;
box2 = “document.form1.” + userid + “_right_2”;
box3 = “document.form1.” + userid + “_right_3”;
box4 = “document.form1.” + userid + “_right_4”;
box5 = “document.form1.” + userid + “_right_5”;
if (box0.checked == false) {
box0.checked = true;
}
}
</script>
</head>
<body>
<form name=”form1″>
<input type=”checkbox” name=”1_right_0″>
<input type=”checkbox” name=”1_right_1″>
<input type=”checkbox” name=”1_right_2″>
<input type=”checkbox” name=”1_right_3″>
<input type=”checkbox” name=”1_right_4″>
<input type=”checkbox” name=”1_right_5″>
<input type=”button” value=”Change” onClick=”checkrights(‘1’)”>
</form>
</body>
</html>
I don’t know much about JS, probably the answer is quite easy, but I didn’t find anything like this using search.
The purpose of this script is simplay to check the checkbox named (name=”1_right_0″). There’ll be some more checkboxes on the page, generated dynamically, the first number of the checkboxes-name will change, so I need a function where I can use a variable user-id.
But somehow using variables like here (box0 = “document.form1.” + userid + “_right_0”; ) doesn’t work.
Anyone can tell me why?