Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 18th, 2005, 06:20 AM
Authorized User
 
Join Date: Jun 2003
Location: Bromsgrove, Worcestershire, United Kingdom.
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default Javascript with <div>

Hi All

I have a page (no form) with a series of check boxes, I have 2 functions to select / deselect all.

Here is one of the functions
function doSelectAll()
{
  var el = document.all;
    for (var i=0; i < el.length; i++)
    {
        if (el[i].type == 'checkbox')
        {
           el[i].checked = true;
        }
     }
}

All the checkboxes are in a table in a div, I also have other checkboxes on the page that I don't want to select.

How do I modify my script to only act on the div or table, and not the whole page. I know the problem is with my document.all but cant figure how to limit it.

Thanks

Andy G
Reply With Quote
  #2 (permalink)  
Old August 18th, 2005, 08:19 AM
Friend of Wrox
 
Join Date: Oct 2004
Location: delhi, delhi, India.
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Hii Aware!!

you can use el[i].name=="urchkboxgrpname"
 el[i].id=="urchkboxgrpname"
so that only checkboxes with particular group can be checked or unchecked

Hope this will help you


Cheers :)

vinod
Reply With Quote
  #3 (permalink)  
Old August 18th, 2005, 08:58 AM
Authorized User
 
Join Date: Jun 2003
Location: Bromsgrove, Worcestershire, United Kingdom.
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

Thanks for the reply.

I cannot use Name as the checkboxes are named - Check & ' Database driven ID'

How do you place a set of checkboxes in a group, I thought that was for radio buttons.

Andy
Reply With Quote
  #4 (permalink)  
Old August 25th, 2005, 05:57 AM
Friend of Wrox
 
Join Date: Oct 2004
Location: delhi, delhi, India.
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Hii Aware!!
Then you can compare the name of checkbox with indexOf("Check")

e.g
ur database driven checkboxes are
 Check123
 Check456

now
 varcheckbox=el[i].name
 if(varcheckbox.indexOf("Check")!=-1)
 {
//this checkbox is not related to Check123 ,Check 456
 }
else{
//this checkbox is related to Check123 ,Check 456
}

hope this will help you

Cheers :)

vinod
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
hide the <div> crmpicco Javascript How-To 1 August 22nd, 2005 09:43 PM
<style> tags in a <body> vs. <div> bcat BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 1 March 27th, 2005 08:50 AM
sizeable <div> johnjohn Javascript How-To 1 December 8th, 2004 08:28 PM
scrolling <DIV> anshul Javascript How-To 12 August 4th, 2004 09:51 AM
<A><DIV><TABLE></DIV></A> anshul HTML Code Clinic 2 July 17th, 2004 02:17 PM



All times are GMT -4. The time now is 09:21 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.