Check a multibox dynamically

View: New views
2 Messages — Rating Filter:   Alert me  

Check a multibox dynamically

by grifoxx :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I have a multibox tag that gets the labels and velues from the data base and I also have a bean that contains the data that the user choose. Now I want to check the boxes each time the user wants to update it's preferences.

1. I display the check boxes with the data comming from the data base
2. I want to compare those values whit the values that the user has
3. If there is a value equals to the value in the current multiboxes, check them

Can anybody help me

Thanks a lot

Re: Check a multibox dynamically

by Uday Karrothi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi thre,

I am trying to give you an example.  Multibox basically fills in using a
string array. i am sure you are aware of that.

<logic:iterate id="apprEntry" name="listDevApprGrpList" indexId="userIndex">
<html:multibox property="toBeAddedList" >
            <bean:write name="apprEntry" property="userID"/>
            </html:multibox></td>
</logic:iterate>

in the code " toBeAddedList" is the string array in the form bean that has
the userID's of the selected users. So, when the check boxes are being
checked , if the userID(<bean:write name="apprEntry" property="userID"/>)
is present in the string array then the checkbox is checked. else no. And
when you try to retrieve the array in the action form the string array
contains all the userID's selected.
in the action form you can set the array and the multibox is populated.
      toBeAddedList[i] = xxxxxxxx.getUserID();

you can even set the checkboxes in the Javascript
function checkAllToBeAddedList()
{
  for(var i=0; i<document.forms[0].toBeAddedList.length; i++)
  {
    document.forms[0].toBeAddedList[i].checked = true;
  }
}


I guess that would have been bad example if you already knew that you could
set multibox and retireve them.

In your logic, i guess in your actionForm you can prepare the string array
based on the logic.

you display the values from the database.
the user makes a selection and submits the form,
you compare that in the action form from the database and then preapre the
string array and the appropriate checkboxes are checked.

I hope that helps.

Thanks
Uday Karrothi


On 10/3/06, grifoxx <pgrapso@...> wrote:

>
>
> Hi,
>
> I have a multibox tag that gets the labels and velues from the data base
> and
> I also have a bean that contains the data that the user choose. Now I want
> to check the boxes each time the user wants to update it's preferences.
>
> 1. I display the check boxes with the data comming from the data base
> 2. I want to compare those values whit the values that the user has
> 3. If there is a value equals to the value in the current multiboxes,
> check
> them
>
> Can anybody help me
>
> Thanks a lot
> --
> View this message in context:
> http://www.nabble.com/Check-a-multibox-dynamically-tf2379274.html#a6630704
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@...
> For additional commands, e-mail: user-help@...
>
>