Hi,

 

I am trying to use the <s:hidden> tag but i am having some problems.

 

What i want to do is to fill the hidden tag with an array that I create
using Javascript.

 

My code:

 

 

* In the jsp part i have this:

 

<a href="<s:url action="Compare.do" includeParams="get"></s:url>"
onclick="return prepareCheckList();" </a>

 

<s:hidden id="compareList" name="compareList" />

 

 

*the Javascript part:

 

 

function prepareCheckList(){

                                   

            var collectionChecks =
document.getElementsByName("checkProduct");

            

            var totalChecked = 0;

            

            var list = newArray();

            

            for(var i=0; i<collectionChecks.length; i++)

            {

                        if (collectionChecks[i].checked){

                                   list[totalChecked] =
collectionChecks[i].value;

                                   totalChecked ++;

                        }

                        

                        if(totalChecked >5 ){

                                   alert("Only 5 can be selected");

                                   return false; //we don't go to the
Compare page.

                        }

            }

            

            document.getElementById("compareList").value = list;

            

            return true;        //we follow the url.

                        

}

 

* In the Action, i have defined:

 

private Collection compareList;

 

public Collection getCompareList() {

            return compareList;

}

 

public void setCompareList(Collection compareList) {

            this.compareList = compareList;

}

 

But i don't manage to get the "compareList" in the Action.

 

 

I don't know if i am doing something wrong in the JavaScript part or if
i am doing something that is not possible.

Can anybody help me??

 

 

Reply via email to