Hi all,
I have write below code in HTML web resource to make checkbox field:
<html>
<head>
<title></title>
<script src="../Scripts/jquery1.11.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
// function will be called when web resource is loaded on Form.
$(document).ready(function () {
ConvertDropDownToCheckBoxList();
});
//Coverts option list to checkbox list.
function ConvertDropDownToCheckBoxList() {
debugger;
var dropdownOptions = parent.Xrm.Page.getAttribute("aw_bant").getOptions();
var selectedValue = parent.Xrm.Page.getAttribute("aw_bantoptionvalues").getValue();
$(dropdownOptions).each(function (i, e) {
var rText = $(this)[0].text;
var rvalue = $(this)[0].value;
var isChecked = false;
console.log(rText);
if (rText != '') {
if (selectedValue != null && selectedValue.indexOf(rvalue) != -1)
isChecked = true;
/* Remove spaces before input, label word and end tags of input & label*/
var checkbox = "< input type='checkbox' name='r'/ >< label> " + rText + "</ label>"
debugger;
$(checkbox)
.attr("value", rvalue)
.attr("checked", isChecked)
.attr("id", "id" + rvalue)
.click(function () {
//To Set Picklist Select Values
var selectedOption = parent.Xrm.Page.getAttribute("aw_bantoptionvalues").getValue();
if (this.checked) {
if (selectedOption == null)
selectedOption = rvalue+"";
else
selectedOption = selectedOption + "," + rvalue
}
else {
var tempSelected = rvalue + ",";
if (selectedOption != null) {
if (selectedOption.indexOf(tempSelected) != -1)
selectedOption = selectedOption.replace(tempSelected, "");
else
selectedOption = selectedOption.replace(rvalue, "");
}
}
parent.Xrm.Page.getAttribute("aw_bantoptionvalues").setValue(selectedOption);
//To Set Picklist Select Text
var selectedYear = parent.Xrm.Page.getAttribute("aw_bantoptions").getValue();
if (this.checked) {
if (selectedYear == null)
selectedYear = rText+"";
else
selectedYear = selectedYear + "," + rText
}
else {
var tempSelectedtext = rText + ",";
if (selectedYear != null) {
if (selectedYear.indexOf(tempSelectedtext) != -1)
selectedYear = selectedYear.replace(tempSelectedtext, "");
else
selectedYear = selectedYear.replace(rText, "");
}
}
parent.Xrm.Page.getAttribute("aw_bantoptions").setValue(selectedYear);
})
.appendTo(checkboxList);
}
});
}
</script>
<meta charset="utf-8">
<meta>
<meta>
<meta>
<meta>
</head>
<body style="word-wrap: break-word;">
<div id="checkboxList">
</div>
</body>
</html>
but my code showing me below output instead of checkbox:

Please tell Where I am wrong?
Thank you
Regards,
*This post is locked for comments
I have the same question (0)