...

View Full Version : set checkboxes.checked in array???



fuzzy1
05-06-2007, 10:17 PM
Hey All,

NEVER MIND, NOW IT WORKS

Can this be done?
<html>
<head>
<script type="text/javascript">
function set_user_mass_flags(){
flag = document.MassUpdate.flag;
user=document.getElementById('currentUser');
for(var i=0; i < document.MassUpdate.flag.length; i++){
if(flag[i].value == user.value)

//alert('hooray');
//flag[i].checked; THIS WAS THE PROBLEM
//NOW IT WORKS, Try it.
flag[i].checked=true;
}
}
window.onload = set_user_mass_flags;
</script>
</head>
<body>
<input type="hidden" name="currentUser" value="450f379a-f9d2">
<form name="MassUpdate" id="MassUpdate">
<input type="checkbox" name="flag" value='450f379a-f9d2'><br>
<input type="checkbox" name="flag" value=''><br>
<input type="checkbox" name="flag" value='450f379a-f9d2'><br>
<input type="checkbox" name="flag" value=''><br>
<input type="checkbox" name="flag" value='450f379a-f9d2'><br>
</form>
</body>
</html>
:confused:

brandonH
05-06-2007, 10:31 PM
may i ask why you have that many checkboxes with the same name? you may be encountering a problem created due to this. 5 check boxes with the same name is like makign a group of radio buttons. doesnt matter what 4 of the 5 are set to, if only one is set to a value (true) then that value holds true for that whole group.

fuzzy1
05-06-2007, 11:38 PM
Sure brandonH,
You CAN ask.

First -- given the realization that I needed to set flag.checked=true; instead of just flag[i].checked; -- let me just say PROBLEM SOLVED.

As for your question "Why?"
I'm dealing with the Contacts module in a contact management app.

In context here, we're listing snapshot values for a given contact record
stored in a mysql db table. (currently only about 5,000 records).

There are numerous coulmns in this view and variable settings to return
anywhere between 20, and 300 rows at a time, counted, filtered, sorted,
and then pagenated as nec. Every field returned in a given collumn has the
same name/id, but is populated with record specific data.
{CONTACT_FIRST_NAME} for example.

The field in question simply flags the record.
(flagging for a mail merge would be just one example use.)

[I]Now, The flags are only visable -- and thereby
useful to -- the users that create them! Neat Huh? :cool::cool: :cool:

Still, I am certain that I have used checbox.checked successfuly in the past?
Or was that just a dream???

p.s I also use many multples of radio buttons in much the same way.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum