본문 바로가기
Java, JavaScript/jQueryMobile

Radio button enable java script

by swconsulting swconsulting 2017. 11. 6.

1) Declare HTML

<div class='fieldset-center-wrapper'>
<fieldset data-role="controlgroup" data-type="horizontal">
<input type="radio" name="radio-choice"
id="null_pm10" value="pm10"
onclick="nullSchoolShowPm10(true)" />
<label for="null_pm10">PM 10</label>

<input type="radio" name="radio-choice"
id="null_pm25" value="pm25"
onclick="nullSchoolShowPm25(true)" />
<label for="null_pm25">PM 2.5</label>

<input type="radio" name="radio-choice"
id="null_pm1" value="pm1"
onclick="nullSchoolShowPm1(true)" />
<label for="null_pm1">PM 1</label>
</fieldset>
</div>


2) Enable Radio button in jQuery Mobile

var pmName = android.getNullPmName();

if(pmName == 'pm10') {
$('input:radio[name="radio-choice"]').filter('[value="pm10"]').attr("checked",true).checkboxradio("refresh");
nullSchoolShowPm10(false);
}
else if(pmName == 'pm2.5') {
$('input:radio[name="radio-choice"]').filter('[value="pm25"]').attr("checked",true).checkboxradio("refresh");
nullSchoolShowPm25(false);
}
else if(pmName == 'pm1') {
$('input:radio[name="radio-choice"]').filter('[value="pm1"]').attr("checked",true).checkboxradio("refresh");
nullSchoolShowPm1(false);
}


댓글0