You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by ha...@informatiefabriek.nl on 2003/04/24 10:43:50 UTC

html:multibox & javascript

Hi all,

In my strutted application I use this code:

<logic:iterate id="attachment" name="attachments" type=
"ordermanager.struts.advertentieoverzicht.UploadForm">
        <html:multibox property="selectedFiles">
                <bean:write name="attachment" property="file"/>
        </html:multibox>
        <bean:write name="attachment" property="file"/>
</logic:iterate>

This code results in the following HTML:

<input type="checkbox" name="selectedFiles" 
value="the-beatles.pdf">the-beatles.pdf
<input type="checkbox" name="selectedFiles" 
value="Im-standing.pdf">Im-standing.pdf

Which is okay. Now in my submit() I want to check if one or more 
checkboxes are checked. (Client side). Therefore I use this javascript:

function validateDelete(form) {
        var count = 0;
      for (var i=0; i<form.selectedFiles.length; i++) {
        if (form.selectedFiles.options[i].selected == true) {
                count++;
        }
 
        if (count == 0) {
                return false;
        }
}

This script works fine if there are more then one entries. But if there 
only is only is one, then the property 'length' does not exist in 
Javascript. So i cannot check it!

How could I check if at least one checkbox is checked?

Thanks,

Harm de Laat
Informatiefabriek



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org