Now I have declared an array variable in my scripting to store all my values of checkboxes. Now I want to use this variable in my html in same view page. How can use a variable in script as well as my html. Can anyone help me in finding the solution for this. And below is my code.
<script type="text/javascript">
function getSelectedChbox(frm) {
//var selchbox = [];
var inpfields = frm.getElementsByTagName('input');
var nr_inpfields = inpfields.length;
for (var i = 0; i < nr_inpfields; i++) {
if (inpfields[i].type == 'checkbox' && inpfields[i].checked == true)
selchbox.push(inpfields[i].value);
}
return selchbox;
}
</script>
<div class="cases">
@foreach (var gim in Model.Details)
{
if (gim.name != selchbox)
{
@Html.Raw(HttpUtility.HtmlDecode(gim.heading))
@Html.Raw(HttpUtility.HtmlDecode(gim.industry))
@Html.Raw(HttpUtility.HtmlDecode(gim.product))
@Html.Raw(HttpUtility.HtmlDecode(gim.description))
}
}
In above code if have used my array variable "sechbox" that I have declared my script but is show an error. Can anyone give me a solution or an alternate solution for this?