문제

One thing I learned today is "there is no selected property in

<html:option>

like plain old option" , we can give value in

<html:select>

that matches the value against each option and if match found marks the option selected.

but I want to make multiple options pre-selected on page load(am using

<html:select multiple="true">

How can it be achieved?

도움이 되었습니까?

해결책

Implement the following:

  1. If possible use JavaScript to make the selected entries true for the multiple entries u had made in that select list
  2. Make it selected by using Java-script first by calling javascript function before any action OR with that action :

function callSelectAll(selectName)  
{   
    var i;  
    for(i=0;i<...) {  
        document.getElementById(selectName).options[i].selected = true;
    }  

}

And use String[] array name as a property name for that html:select property form bean property. And the name of that array as a property of that html:select in jsp page.

You will ultimatly gate the all selected values un the that string array of form bean.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top