ASP.NET Javascript Checkbox Question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dougloj@comcast.net

    #1

    ASP.NET Javascript Checkbox Question

    I'm developing an ASP.Net application that uses checkboxes. I am trying
    to use client-side Javascript to capture the clicking of a checkbox
    when it happens via the OnClick event.

    In my .aspx file, I might have the checkbox coded as follows:

    <asp:CheckBox onclick="SeeCli ck(this);" AutoPostBack="F alse"
    Visible="True" ID="CheckBox1" Text="Selection 1"
    runat="server"> </asp:CheckBox>

    The HTML that gets sent to the browser for this is:

    <span onclick="SeeCli ck(this);"><inp ut id="CheckBox1" type="checkbox"
    name="CheckBox1 " /><label for="CheckBox1" >Selection1</label></span>

    In my Javascript SeeClick function, I do a few things to see if the
    actual checkbox has been checked or not. That's fine. But if the user
    clicks on the label next to the checkbox, the SeeClick function is
    called twice, and that screws things up, because on one of the calls, I
    get an invalid reading of the "checked" attribute. I have no way of
    knowing if the user clicked the checkbox or the lable.

    Does anybody have any ideas on how to deal with this? Thanks in
    advance.

    - Doug

  • kaeli

    #2
    Re: ASP.NET Javascript Checkbox Question

    In article <1109756220.400 420.174580@l41g 2000cwc.googleg roups.com>,
    dougloj@comcast .net enlightened us with...[color=blue]
    >
    > I have no way of
    > knowing if the user clicked the checkbox or the lable.[/color]

    Sure you do. Check the object type. (typeof)

    if (typeof varname == "checkbox")

    --
    --
    ~kaeli~
    Practice safe eating - always use condiments.



    Comment

    • dougloj@comcast.net

      #3
      Re: ASP.NET Javascript Checkbox Question

      Thanks for your input, however typeof simply returns "object"
      regardless of whether the checkbox or the lable is clicked. Is there
      something that I'm missing?

      TIA

      - Doug

      Comment

      Working...