I have a form and a dropdown as below:
I have written validation alerts for other fields which are above this drop-down. But when any of the validation triggers, this drop-down is not being repopulated after page reload and is being displayed as below:
I have the below in my jsp:
<tr><td>
<stripes:checkbox name="policyShow" onclick="handleDisable(policyShow, policyNumber,null)"/><stripes:label for="DealerTransactionReport.policy" /></td>
<td>
<stripes:select name="policyNumber" disabled="${!actionBean.policyShow}" onchange="handleSelectedAll();">
<stripes:options-collection collection="${actionBean.policyList}" value="policyNumber" label="description" />
</stripes:select>
</td>
</tr>
I tried writing an onchange function but nothing worked so far and I currently have below code:
function handleSelectedAll()
{
var select = document.forms['dealerTransactionForm'].policyNumber.options[document.forms['dealerTransactionForm'].policyNumber.selectedIndex].index;
if(select== 0 )
{
document.forms[dealerTransactionForm].searchTxt.value="";
}
}
Can someone please suggest how do I solve this problem??.
That is because you are loosing data during the postback. You need to fetch data during the page load regardless of the selected value of the dropdown-list. Please be noted that only the selected value is passed to the server and not all select options.