take checkbox checked value name dynamically using Jquery MVC3
I have this views

view1

      @if (@Model.QuestionType == 3)
     {
    <div data-role="fieldcontain">
        @using (Html.BeginForm("SaveCheckbox", "GetQuestion", Model))
        {
            @Html.AntiForgeryToken() 
            <fieldset data-role="controlgroup" id="@(Model.QuestionNo)_fld">
                <label class="select">@Model.QuestionText
                </label>
                <br />
                @foreach (var item in Model.Options)
                {
                    if (@item.IsAnswer == true)
                    {
                    <input type="checkbox" checked="checked" name="selectedObjects" id="@(Model.QuestionNo)_@(item.OptionNumber)_chk" value="@item.OptionNumber" class="custom"  />
                    }
                    else
                    {
                    <input type="checkbox"  name="selectedObjects" id="@(Model.QuestionNo)_@(item.OptionNumber)_chk" value="@item.OptionNumber" class="custom"   />   
                    }
                    <label for="@(Model.QuestionNo)_@(item.OptionNumber)_chk">
                        @item.OptionText</label> 
                }
                <br />
            </fieldset>
            <p>
                <input type="submit" id="@(Model.QuestionNo)_chk" onclick="return SaveCheckBoxNew(this);" value="Next" />
            </p>
        }
    </div>
      }
 
       @if (@Model.QuestionType == 4)
      {
       <div data-role="fieldcontain">
        @using (Html.BeginForm("SaveCheckBoxTextInput", "GetQuestion", Model))
        {
            @Html.AntiForgeryToken() 
            <fieldset data-role="controlgroup" id="@(Model.QuestionNo)_fld">
                <label id="l3" for="select-choice-1" class="select">@Model.QuestionText
                </label>
                <br />
                @foreach (var item in Model.Options)
                {

                    if (@item.IsAnswer == true)
                    {
                        if (@item.OptionText == "Other")
                        {
                    <input type="checkbox" checked="checked" name="selectedObjects" questionid="@Model.QuestionNo" other="true" id="@(Model.QuestionNo)_@(item.OptionNumber)_chk" value="@item.OptionNumber" onchange="selectCheckbox(this);" />
                    <input type="text" value="@item.Answer" name="selectedObjects" id="@(Model.QuestionNo)_chktxt"/>
                        }
                        else
                        {
                    <input type="checkbox" checked="checked" name="selectedObjects" questionid="@Model.QuestionNo" other="false" id="@(Model.QuestionNo)_@(item.OptionNumber)_chk" value="@item.OptionNumber" onchange="selectCheckbox(this);" />
                        }
                    }
                    else
                    {
                        if (@item.OptionText == "Other")
                        {
                    <input type="checkbox" name="selectedObjects" questionid="@Model.QuestionNo" other="true" id="@(Model.QuestionNo)_@(item.OptionNumber)_chk" value="@item.OptionNumber" onchange="selectCheckbox(this);" />
                    <input type="text" name="selectedObjects" id="@(Model.QuestionNo)_chktxt" style="display: none;" />
                        }
                        else
                        {
                    <input type="checkbox" name="selectedObjects" questionid="@Model.QuestionNo" other="false" id="@(Model.QuestionNo)_@(item.OptionNumber)_chk" value="@item.OptionNumber" onchange="selectCheckbox(this);" />
                        }
                    }
                    
                    <label for="@(Model.QuestionNo)_@(item.OptionNumber)_chk">
                        @item.OptionText</label> 
                }
                <br />
            </fieldset>
            <p>
                <input type="submit" id="@(Model.QuestionNo)__chktxtinput" value="Next" onclick="return validateCheckBoxTextInput(this);" />
            </p>
        }
    </div>
     }

i am rendering the same view based on question types.
so i have written separate javascripts like this for both

for 1:
       function SaveCheckBoxNew(button) {
	alert($('input:radio[name=selectedObjects]:checked').val());
       }
for 2 :
      function validateCheckBoxTextInput(button){
	alert($('input:radio[name=selectedObjects]:checked').val());
      }
so if i do not check any checkbox in the second view it is showing the same value as selected in firtst view.

i have to get the null if any checkbox is not checked in the second why the selectednameobjects is not cleared.

how do i solve this ?
thanks in advance for your help .
 
take checkbox checked value name dynamically using Jquery MVC3
===

I have this views

view1

      @if (@Model.QuestionType == 3)
     {
    <div data-role="fieldcontain">
        @using (Html.BeginForm("SaveCheckbox", "GetQuestion", Model))
        {
            @Html.AntiForgeryToken() 
            <fieldset data-role="controlgroup" id="@(Model.QuestionNo)_fld">
                <label class="select">@Model.QuestionText
                </label>
                <br />
                @foreach (var item in Model.Options)
                {
                    if (@item.IsAnswer == true)
                    {
                    <input type="checkbox" checked="checked" name="selectedObjects" id="@(Model.QuestionNo)_@(item.OptionNumber)_chk" value="@item.OptionNumber" class="custom"  />
                    }
                    else
                    {
                    <input type="checkbox"  name="selectedObjects" id="@(Model.QuestionNo)_@(item.OptionNumber)_chk" value="@item.OptionNumber" class="custom"   />   
                    }
                    <label for="@(Model.QuestionNo)_@(item.OptionNumber)_chk">
                        @item.OptionText</label> 
                }
                <br />
            </fieldset>
            <p>
                <input type="submit" id="@(Model.QuestionNo)_chk" onclick="return SaveCheckBoxNew(this);" value="Next" />
            </p>
        }
    </div>
      }
 
       @if (@Model.QuestionType == 4)
      {
       <div data-role="fieldcontain">
        @using (Html.BeginForm("SaveCheckBoxTextInput", "GetQuestion", Model))
        {
            @Html.AntiForgeryToken() 
            <fieldset data-role="controlgroup" id="@(Model.QuestionNo)_fld">
                <label id="l3" for="select-choice-1" class="select">@Model.QuestionText
                </label>
                <br />
                @foreach (var item in Model.Options)
                {

                    if (@item.IsAnswer == true)
                    {
                        if (@item.OptionText == "Other")
                        {
                    <input type="checkbox" checked="checked" name="selectedObjects" questionid="@Model.QuestionNo" other="true" id="@(Model.QuestionNo)_@(item.OptionNumber)_chk" value="@item.OptionNumber" onchange="selectCheckbox(this);" />
                    <input type="text" value="@item.Answer" name="selectedObjects" id="@(Model.QuestionNo)_chktxt"/>
                        }
                        else
                        {
                    <input type="checkbox" checked="checked" name="selectedObjects" questionid="@Model.QuestionNo" other="false" id="@(Model.QuestionNo)_@(item.OptionNumber)_chk" value="@item.OptionNumber" onchange="selectCheckbox(this);" />
                        }
                    }
                    else
                    {
                        if (@item.OptionText == "Other")
                        {
                    <input type="checkbox" name="selectedObjects" questionid="@Model.QuestionNo" other="true" id="@(Model.QuestionNo)_@(item.OptionNumber)_chk" value="@item.OptionNumber" onchange="selectCheckbox(this);" />
                    <input type="text" name="selectedObjects" id="@(Model.QuestionNo)_chktxt" style="display: none;" />
                        }
                        else
                        {
                    <input type="checkbox" name="selectedObjects" questionid="@Model.QuestionNo" other="false" id="@(Model.QuestionNo)_@(item.OptionNumber)_chk" value="@item.OptionNumber" onchange="selectCheckbox(this);" />
                        }
                    }
                    
                    <label for="@(Model.QuestionNo)_@(item.OptionNumber)_chk">
                        @item.OptionText</label> 
                }
                <br />
            </fieldset>
            <p>
                <input type="submit" id="@(Model.QuestionNo)__chktxtinput" value="Next" onclick="return validateCheckBoxTextInput(this);" />
            </p>
        }
    </div>
     }

i am rendering the same view based on question types.
so i have written separate javascripts like this for both

for 1:
       function SaveCheckBoxNew(button) {
	alert($('input:radio[name=selectedObjects]:checked').val());
       }
for 2 :
      function validateCheckBoxTextInput(button){
	alert($('input:radio[name=selectedObjects]:checked').val());
      }
so if i do not check any checkbox in the second view it is showing the same value as selected in firtst view.

i have to get the null if any checkbox is not checked in the second why the selectednameobjects is not cleared.

how do i solve this ?
thanks in advance for your help .
 