You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Zimmer, Robin (SSABSA)" <ro...@ssabsa.sa.gov.au> on 2002/07/30 08:15:47 UTC

hidden fields and String[]

I have a form bean that has an array of strings that are supposed to hold
the selected items from a multibox. The architect has asked that when the
roiginal form is submitted, I display the selected items on a new form as
part of a confirmation process. When the Yes button is pressed the contents
of the string array (selected items) must be submitted. To accomplish this I
am trying to use hidden fields to hold the content of the String[] but am
getting no where. I realise that I have to iterate somehow over the array,
but have nver thried this with a String[] and hidden fields. Can someone
please help.

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: hidden fields and String[]

Posted by Stan Baranek <st...@gene.COM>.
Hi Robin,

If you just want to use javascript to prompt the user, showing the 
selected fiields you can iterate through your form fields like this:

    var elementLength = window.document.SearchForm.elements.length;
    spacer = " ";
    userMsg = "Hey user - Click yes if you want to select ";
    for (var eachElement = 0;eachElement < elementLength; eachElement++)
    {
        var theElement = window.document.SearchForm.elements[eachElement];
        if ((theElement.name == 'MyFieldName') ||
            (theElement.name == 'YourFieldName')
        {
            userMsg+= spacer + theElement.value;
        }
        spacer = ", ";
    }
    if (prompt(userMsg)) {
         submit or whatever here...
     }

Regards,
Stan

Zimmer, Robin (SSABSA) wrote:

>I have a form bean that has an array of strings that are supposed to hold
>the selected items from a multibox. The architect has asked that when the
>roiginal form is submitted, I display the selected items on a new form as
>part of a confirmation process. When the Yes button is pressed the contents
>of the string array (selected items) must be submitted. To accomplish this I
>am trying to use hidden fields to hold the content of the String[] but am
>getting no where. I realise that I have to iterate somehow over the array,
>but have nver thried this with a String[] and hidden fields. Can someone
>please help.
>
>--
>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>  
>




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>