Hi, I have one script that should check for a couple of checkboxes which one of them is checked, and store their values, then post them back to the controller(it's an MVC application, but that is not that much important). I am doing this using an additional hidden input field, like this:

<% 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:

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:

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,

There's too much information missing for me to check, but if I had to guess, I would look into when the informations is loaded versus when it is checked.

Nope, I'm afraid you're wrong :) I checked for that option, too, but I'm pulling the values from a database and they're fine. But I managed to solve it with a little from my friends, so thank you anyways. The problem were the stupid hidden fields :), I managed to throw them and the javascript away, and now it's fine, the array contains the values, separated by a comma, so when I separate it I get the values. Thanks a lot, redargs