473,669 Members | 2,421 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

can't detect status of checkbox

TJS

trying to detect status of the checkbox to produce an alert
can someone guide me to a fix on this?
<input id="badcustomer s" type="checkbox" checked name="badcustom ers"
.............. .

<script language ="javascript ">
var part1, part2, part3, isNN;
function setVariables() {
if (navigator.appN ame == "Netscape") {
isNN = true;
if(!document.al l && document.getEle mentById) {
part1="document .getElementById .";
part3 = "";
} else {
part1="document .";
part3="";
}
}
else {
part1 = "document.all." ;
part3 = "";
}
}

if( eval(part1 + "badcustome rs" + ".checked") ){
alert("This is a bad customer");
}
</script>
Jul 23 '05 #1
3 4138
TJS wrote:
trying to detect status of the checkbox to produce an alert
can someone guide me to a fix on this?
<input id="badcustomer s" type="checkbox" checked name="badcustom ers"

>.............. .

<script language ="javascript ">
var part1, part2, part3, isNN;
function setVariables() {
if (navigator.appN ame == "Netscape") {
isNN = true;
if(!document.al l && document.getEle mentById) {
part1="document .getElementById .";
part3 = "";
} else {
part1="document .";
part3="";
}
}
else {
part1 = "document.all." ;
part3 = "";
}
}

if( eval(part1 + "badcustome rs" + ".checked") ){
alert("This is a bad customer");
}
</script>

You get the award for "worst snippet of the week". No contest.
Client-sniffing, language attribute, and - naturally - scripting in
'string language' with the help of our old *friend* eval().

How about something exotic like...

document.getEle mentById('badcu stomers').check ed

....or

document.forms[0].elements.badcu stomers.checked
....for better support. Almost 2005 now. Merry Xmas. ;)

Jul 23 '05 #2
TJS
glad you liked it :)
"RobB" <fe******@hotma il.com> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
TJS wrote:
trying to detect status of the checkbox to produce an alert
can someone guide me to a fix on this?
<input id="badcustomer s" type="checkbox" checked name="badcustom ers"

>.............. .

<script language ="javascript ">
var part1, part2, part3, isNN;
function setVariables() {
if (navigator.appN ame == "Netscape") {
isNN = true;
if(!document.al l && document.getEle mentById) {
part1="document .getElementById .";
part3 = "";
} else {
part1="document .";
part3="";
}
}
else {
part1 = "document.all." ;
part3 = "";
}
}

if( eval(part1 + "badcustome rs" + ".checked") ){
alert("This is a bad customer");
}
</script>

You get the award for "worst snippet of the week". No contest.
Client-sniffing, language attribute, and - naturally - scripting in
'string language' with the help of our old *friend* eval().

How about something exotic like...

document.getEle mentById('badcu stomers').check ed

...or

document.forms[0].elements.badcu stomers.checked
...for better support. Almost 2005 now. Merry Xmas. ;)

Jul 23 '05 #3
JRS: In article <11************ **********@z14g 2000cwz.googleg roups.com>,
dated Sun, 19 Dec 2004 13:49:47, seen in news:comp.lang. javascript, RobB
<fe******@hotma il.com> posted :

You get the award for "worst snippet of the week". No contest.
Client-sniffing, language attribute, and - naturally - scripting in
'string language' with the help of our old *friend* eval().

However, he did indent the code, which makes the intended logical
structure much more apparent to readers (although using units of two
spaces is, for me at least, preferable); and he did not double-space or
mis-wrap it.

There's an implied <FAQENTRY> there, for 2.3 paragraphs 4 & 6.

Possible FAQ Question 4.0 - "How should javascript be written" - answer
to include indent & paragraph, spaces, line-length for News, and probably
a link to FAQ notes. Praise plaintext editing, validators, etc., and
knock inferior composing packages, if those can be done briefly.

It's FA, even if not a FQ !

The "can not" in the FAQ (4.33) should, as everywhere else, be "cannot".

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 23 '05 #4

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

Similar topics

1
1351
by: Vannela | last post by:
I want to get the status of the checkbox control in the item template of the DataList in the code behind Using findcontrol i am not able to get the status of the checkbox . How shouls i get the status of the checkbox whether it is checked or not?\ Thank you
1
3775
by: VB Programmer | last post by:
Simple: I have a datalist that is holding a bunch of job opportunities. Beside each opp (in the item template) there's a checkbox that says "apply". After the datalist there's a button that say's "process". I want to LOOP through each datalist entry and see if the user checked the check box. Simple. I wrote the code, but the checked value is ALWAYS False. Any ideas? Here's the code...
2
1022
by: Andrew | last post by:
Hi, I display a repeater in a web page, when i click on the next button, I want to loop thru the repeater to detect the checkbox controls. Previously this code works, but now .... I used the debugger n found that the program cannot even detect the repeater control coz it just skips past this line. I have listed a abbrev. version of my code below: private void btnNext_Click(object sender, System.EventArgs e) {
0
1348
by: Paul | last post by:
Hello, I have a datagridview with a checkbox in a column, and I want to detect when the user change the value of the checkbox in the event CheckedChanged, but I only detect that the value is changed when the focus is in another column. An idea? Thanks
4
1902
by: _Raven | last post by:
Okay, I am playing with submitting forms with Ajax. I am trying to adapt this script to my forms: http://www.captain.at/howto-ajax-form-post-get.php I have included my code at the bottom of this post. Basically, this will work correctly if I remove all non-form related tags from the form =eg span, div, but I want to format the form all pretty like so??? Right now, it only collects 2 parts of the form fields =sites &
2
23824
by: Dan D | last post by:
I have a large install file (an exe) on my web server that people download and install from. Looking at my log files, I see a lot of people downloading it, but no way to tell for sure if they completed the download or cancelled out before it completed. Is there any function in PHP that would allow the web server to send the file and detect a completion or cancellation? Or perpahs a javascript/PHP method? Any help would be greatly...
0
1177
by: Ryan Liu | last post by:
I have a DataGrid with only one column is editable. It is a DataGridViewCheckBoxColumn. I want to detect if the any checkbox state is changed. So I listen to ColumnChanged event. But whenever user click the checkbox, and checkbox state changed, but the event is not fired until the user click anywhere else in the grid or in the parent form.
2
2875
by: waleed | last post by:
I'm not really good with javascript, basically what I'm trying to do is that I want to be able to handle when the status of a checkbox is changed (i.e. checked or unchecked), I see everybody is using onclick but I wonder if this is the correct approach, what if a user changes the status of the checkbox using the keyboard, will onclick be triggered? I know I might sound a little picky here but I believe those people who created DHTML...
5
3675
by: bjwest | last post by:
I'm writing a windows mobile app that uses dynamiclly created checkboxes. I'm having trouble getting the checked status. public void Add_CheckBox(String CBText) { CheckBox MyCheckbox = new CheckBox(); MyCheckbox.Location = new System.Drawing.Point(4, CB_Row * 20); MyCheckbox.Name = "MycheckBox" + CB_Row; MyCheckbox.Text = CBText; MyCheckbox.Font = NormalFont; ...
0
8383
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8895
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8809
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7407
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6210
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5682
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4206
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4386
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1788
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.