简体   繁体   中英

Default Radio button selected value

In the following code how do I make sure that the Default radio button selected is always Period ?? Currently when the page is loaded , non is selected in the radio button.

<tr>
    <th valign="top" align="left">
        Scope 
        <span class="required">*</span>
    </th>
    <td align="left">
        <p class="error-message" id="span_scopeType"></p>
        <s:radio name="scopeType" id="scopeType" list="#{'PERIOD':'Period','MONTH':'Month','CUSTOM':' Custom'}" value="%{scopeType}" onchange="loadReport(this)"></s:radio>
    </td>
</tr>

HTML input type radio has a "checked" attribute, you can use this so that on load a specific option is checked.

<input type="radio" name="sex" value="male">Male<br>
<input type="radio" name="sex" value="female" checked="checked">Female

I hope this resolves your issue.

Further information: HTML DOM Object: Radio Button

You can use this in through angular2

 class onInitRadio { selected = {"value":"X"}; } 
 <md-radio-group class="form-control" [(ngModel)]="selected.value" id="radioGroup" formControlName="selected"> <md-radio-button [value]="'X'">X</md-radio-button> <md-radio-button [value]="'Y'">Y</md-radio-button> </md-radio-group> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM