using jquery to make only 1 checkbox is selected

I have a modal window that has  a gridview whichs could list form 1 to 8 individuals.  Each record has a check box next to it as shown in picture.  How do I make sure that when a checkbox is selected that any other ones are not.  I only want 1 checkbox to be selected at a time.

Here is html
     <asp:GridView ID="GridView1" runat="server" CssClass="table table-bordered table-striped table-responsive pagination-ys" AutoGenerateColumns="false">
                             
                    <Columns>
                        
                        <asp:TemplateField HeaderText="Select (1)">
                            <ItemTemplate>
                                <asp:CheckBox runat="server" ID="ckbSelect" selected="false"  AutoPostBack="True" OnCheckedChanged="CheckedBoxes" />
                                </ItemTemplate>
                            
                        </asp:TemplateField>
                        
                        <asp:TemplateField HeaderText="OccuSeqNo" Visible="false">
                           
                            <ItemTemplate>
                                <asp:Label ID="Label1" runat="server" Text='<%# Bind("OccuSeqNo")%>' ></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        
                        <asp:TemplateField HeaderText="Name">
                           
                            <ItemTemplate>
                                <asp:Label ID="Label2" runat="server" Text='<%# Eval("OccuFirstName") & " " & Eval("OccuLastName")%>'></asp:Label>
                            </ItemTemplate> 
                        </asp:TemplateField>      
                         <asp:TemplateField HeaderText="Birthdate">
                           
                            <ItemTemplate>
                                <asp:Label ID="Label3" runat="server" Text='<%# Eval("birthdate", "{0:d}")%>'></asp:Label>
                            </ItemTemplate> 
                        </asp:TemplateField>    
                        
                           <asp:TemplateField HeaderText="SSNum">
                           
                            <ItemTemplate>
                                <asp:Label ID="Label4" runat="server" Text='<%# Eval("SSNum")%>'></asp:Label>
                            </ItemTemplate> 
                        </asp:TemplateField>                  
                    </Columns>
                    <PagerStyle CssClass="table" />

                </asp:GridView>

Open in new window


Here is a picture of modal window
picture of gridview.
mgmhicksAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Pravin AsarPrincipal Systems EngineerCommented:
>>How do I make sure that when a checkbox is selected that any other ones are not

You can use radio button
Rainer JeschorCommented:
Hi,
if these are the only checkboxes in your HTML document, then the following should work:
$(document).ready(function() {
    $("input:checkbox").click(function() {
        $("input:checkbox").prop("checked", false);
        this.checked = true;
    });
});

Open in new window

Live sample:
http://jsfiddle.net/EE_RainerJ/aunvpgsb/

Now the checkboxes work like radio buttons.
Perhaps you should additionally implement a button / function to reset /clear a set checkbox.
HTH
Rainer

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mgmhicksAuthor Commented:
Rainer this is what is in html when I run the page.

<input id="MainContent_GridView1_ckbSelect_1" type="checkbox" name="ctl00$MainContent$GridView1$ctl03$ckbSelect" checked="checked" onclick="javascript:setTimeout('__doPostBack(\'ctl00$MainContent$GridView1$ctl03$ckbSelect\',\'\')', 0)">

The script may have to be changed since this in working within a master page?

the script doesn't work as it is now.
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Rainer JeschorCommented:
Hi,
first of all you should not add the script to the master page but to the content page which is the modal window.
Second I am not sure what you have coded to have this postBack event in the onclick.
Can you verify using Chrome or IE Dev Tools (F12), setting a breakpoint on the click function if this is getting called?
Thanks and HTH
Rainer
mgmhicksAuthor Commented:
ok, let me remove the onclick event, and the script is on the content page, not the master page, but it is within a modal window.

thanks, try it after removing onclick.
mgmhicksAuthor Commented:
After removing the onclick event (which I only had when jquery wasn't working) it worked like you said.  Great Code!  Thank you
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.