473,386 Members | 1,973 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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="SeeClick(this);" AutoPostBack="False"
Visible="True" ID="CheckBox1" Text="Selection1"
runat="server"></asp:CheckBox>

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

<span onclick="SeeClick(this);"><input 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

Jul 23 '05 #1
2 1324
In article <11**********************@l41g2000cwc.googlegroups .com>,
do*****@comcast.net enlightened us with...

I have no way of
knowing if the user clicked the checkbox or the lable.


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

if (typeof varname == "checkbox")

--
--
~kaeli~
Practice safe eating - always use condiments.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #2
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

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: VK | last post by:
09/30/03 Phil Powell posted his "Radio buttons do not appear checked" question. This question led to a long discussion about the naming rules applying to variables, objects, methods and properties...
2
by: neoconwannabe | last post by:
Hi, I have an html form with a number of checkboxes that can be checked to delete items. I want to have a javascript alert prompt box to pop up to confirm the delete. I am building my site with...
6
by: den 2005 | last post by:
Hi everybody, Question 1: How do you set the values from server-side to a client-side control or how do you execute a javascript function without a button click event? Question 2: How do you...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.