- Code: Select all
<% for(int i = 0; i < Model.Languages.Count; i++)
{ %>
<input name="applang" type="checkbox" value="<%: Model.Languages[i].languageID %>" />
<input type="hidden" id="hiddenFieldDemo" name="hiddenFieldDemoName" />
<%: Model.Languages[i].name.ToString() %><br />
<%} %>
here's the script:
- Code: Select all
function get_check_value() {
var hiddenFieldDemoVar = document.getElementById('hiddenFieldDemo');
for (var i = 0; i < document.addLangForm.applang.length; i++) {
if (document.addLangForm.applang[i].checked) {
hiddenFieldDemoVar.value = hiddenFieldDemoVar.value + document.addLangForm.applang[i].value + ' ';
}
}
So, now when I try to get the values in the backend code, like this:
- Code: Select all
string hiddenFieldDemoStringArray = Request.Form["hiddenFieldDemoName"];
I get just three comma values, i.e. - ",,,". I should probably mention that there are 4 checkboxes and currently I am selecting just one of them, the first one, so I expect this string hiddenFieldDemoStringArray to get the value - "1". But, I get the commas instead.
Any help would be appreciated.
Kind regards,
aDameToKillFor


