Frage

I have a text box in JSP as below:

<INPUT TYPE="text" readonly="readonly" NAME="IssueFlag" ID="IssueFlag" SIZE="45" class="allcaps" maxlength="49" value="<%=mySearchTO.getIssueFlag()%>">

It will display value Yes or No based on whether the flag is set or not.

I want to replace it with checkbox where the checkbox should be checked if the value is Yes else unchecked.

How can I put it ?

For e.g. in case of dropdown I am doing something like:

<select name="dropdown">     
    <option value="one" ${param.dropdown == 'one' ? 'selected' : ''}>One</option>     
    <option value="two" ${param.dropdown == 'two' ? 'selected' : ''}>Two</option>     
    <option value="three" ${param.dropdown == 'three' ? 'selected' : ''}>Three</option>   
</select>

But how to achieve such functionality with checkbox.

Thanks for reading!

War es hilfreich?

Lösung

In Scriplet,

<input type="checkbox" name="checkboxName" value"checkBoxValue" 
<%=mySearchTO.getIssueFlag()?"Checked":""%>

In EL,

<input type="checkbox" name="checkboxName" value"checkBoxValue" 
${mySearchTO.issueFlag()?"Checked":""}>

I prefer EL

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top