473,543 Members | 2,550 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

checkboxes and javascripts in .net

14 New Member
i have a checkbox
[HTML]<input name="AllCompan ies" id="Checkbox3" type="checkbox" onclick=chkall1 () checked/>All Companies
[/HTML]On this onclick I have called the below javascript

Expand|Select|Wrap|Line Numbers
  1. function chkall1()
  2. {
  3. if(document.getElementById("Checkbox3").checked=true)
  4. {
  5. document.getElementById("Checkbox3").checked=false;
  6. for (var n=0; n < document.forms[3].length; n++)
  7. {
  8. if (document.forms[3].elements[n].type=='checkbox' && document.forms[3].elements[n].id!='Checkbox3')
  9. {
  10. document.forms[3].elements[n].checked=false;
  11. document.forms[3].elements[n].disabled=false;
  12. }
  13. }
  14. }
  15. else
  16. {
  17. document.getElementById("Checkbox4").checked=true;
  18. for (var n=0; n < document.forms[3].length; n++)
  19. {
  20. if (document.forms[3].elements[n].type=='checkbox' && document.forms[3].elements[n].id!='Checkbox4')
  21. {
  22. document.forms[3].elements[n].checked=true;
  23. document.forms[3].elements[n].disabled=true;
  24. }
  25. }
  26. }
  27. return false;
  28. }
When I execute this the output is
The all companies check box is checked in the output.

Now the thing I need is when I click on the checked all companies checkbox it must be unchecked and all the checkboxes below this checkbox must be enabled and checked.for this I have written the javascript. When I click it for second time I need the checkbox to be checked for which I have written the else part in javascript and it doesnot work.it works for only one click
Aug 17 '07 #1
2 1281
kestrel
1,071 Recognized Expert Top Contributor
Hey rathiagu, Welcome To The Scripts!
Im going to move this question to the Javascript forum. Have a nice day!

--
Kestrel
Aug 17 '07 #2
acoder
16,027 Recognized Expert Moderator MVP
Please use CODE tags when posting code.

On line 3, you're setting instead of checking the checked property, i.e. you need double equals (==) instead of single (=).
Aug 17 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
2394
by: Kerberos | last post by:
When I deliver a page as text/html, the javascripts work, but if delivered as application/xhtml+xml, the javascripts don't work: function OpenBrWindow(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0 if(window.screen)if(isCenter)if(isCenter=="true"){ var myLeft = (screen.width-myWidth)/2; var myTop =...
2
2374
by: sdvoranchik | last post by:
We have an application that contains links that run javascripts to create pages in a separate frame. When these links open an external site, it causes the javascripts to no longer function. When we modified the links that invoke the javascripts from: <a href=javascript: top.doSomething> text </a> To: <span...
2
1769
by: LC's No-Spam Newsreading account | last post by:
I asked a couple of days ago about the following arrangement (simplified). I made some progress using netscape.security.PrivilegeManager.enablePrivilege but still have to ask some further help. 1) a frameset contains - a number of javascript functions in the head (they do something like top.frames.document.myform.elements.value = v - two...
3
1818
by: claudel | last post by:
Hi I have a newb PHP/Javascript question regarding checkbox processing I'm not sure which area it falls into so I crossposted to comp.lang.php and comp.lang.javascript. I'm trying to construct a checkbox array in a survey form where one of the choices is "No Preference" which is checked by default. If the victim chooses other than "No...
4
2335
by: David Virgil Hobbs | last post by:
My web host inserts banner ads into my html pages. The javascript in these banner ads interferes with the onload triggered javascript functions in my pages. Whether I trigger my javascript functions through onload=function() in the body tag or through window.onload=function name in a script, the host's advertising javascripts disrupt my...
4
4060
by: swayze | last post by:
Hi, I'm sending some vars to php from javascript. These vars contain special chars (like "&" ,",")and also turkish characters. Therefore I'm using javascripts escape() function to be able to send them properly. My problem is on the php side. I am using rawurldecode to convert them back. However, Turkish characters like "I" (capital "I"...
4
1808
by: januarynow | last post by:
Generally, my site contains javascripts (a couple of freebie counters plus some CPM (pay-per-impression) and CPC (pay-per-click) ads), from four different firms, but they are all suffering from the same problem: every day, they have a 90%+ failure rate, in detecting traffic. My server log keeps reporting that numerous people visit the site, but...
4
1843
by: cvijaykrishna | last post by:
hi, i am having an apllication which has a multiview if i check one checkbox in a view other checkboxin another view should get checked . i am using server side script and getting it but for immediate results we need to put Autopostback=true for those checkboxes.But i want to use javascripts for this operation can we use it. plese help me in...
0
7399
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
1
7332
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7677
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5258
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...
0
4884
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...
0
3385
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...
1
1809
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
952
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
626
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...

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.