Hi All,
I am very new to jQuery, but I have checked over my code several times and cannot find what I've done wrong with my first script, which is to check/uncheck all checkboxes in a html form. Nothing is checking or unchecking, and I am seeing the "Error on this page" in IE whenever i first click one of the two buttons.
Here are the steps I have taken
1. I have imported the jQuery library which I have just downloaded (1.4.2 development version, 155kb) with the following code:
- < script type = "text/javascript" src = "styles/jquery.js" > </ script >
For the record, the script is definitely in the correct location, under the correct name.
2. I also have the following function in my "head" tags.
- < script type = "text/javascript" >
- function CheckAll( id, name, flag )
- {
- if (flag == 0 )
- {
- $( "form#" + id + " INPUT[@name=" + name + "][type='checkbox']" ).attr( 'checked' , false);
- }
- else
- {
- $( "form#" + id + " INPUT[@name=" + name + "][type='checkbox']" ).attr( 'checked' , true);
- }
- }
- </ script >
Which I didn't think was a problem (I will be reusing the function many times in different forms with different checkbox names in my site)
3. I have a form with a name of "news" and id of "news" also, and checkboxes like this:
- <input class="check" type="checkbox" name="deletenews" value="1" />
as you can see, the name being "deletenews"
4. Finally, my check and uncheck buttons are as follows
- <input class="button" type="button" value="Select All" name="CheckAll" onclick="CheckAll('news', 'deletenews', 1);" />
- <input class="button" type="button" value="De-Select All" name="UnCheckAll" onclick="CheckAll('news', 'deletenews', 0);" />
I would much appreciate any help, and i'm sorry for the long post, just wanted to make sure you knew everything I was trying to do to save time.
Regards,
Jason