Hi all,
I’m new to these forums, and a complete novice when it comes to Javascript, so I thought I’d dive right in and ask a question that I hope someone can help me answer.
A web page I’m creating will allow a visitor to download a number of PDF files. A form on the page has one checkbox for each of the PDF files. I also wanted to add a checkbox to select/deselect all the PDFs.
I hunted around the web and found the following Javascript code:
function checkedAll (frm1) {
var aa= document.getElementById('pdf_form');
if (checked == false)
{
checked = true
}
else
{
checked = false
}
for (var i =0; i < aa.elements.length; i++)
{
aa.elements[i].checked = checked;
}
}
My form has an ID of pdf_form and I call the above code from the onclick event of the select all/deselect all checkbox:
<p><input name="checkall" type="checkbox" class="pdf_checkbox" value="" onclick='checkedAll(pdf_form);' /> Select / Deselect all</p>
All works fine, but I also want the visitor to supply their name and email address before downloading, so I want to add another checkbox before the submit button to allow them to opt in/out of having their email address used for further mail shots.
Unfortunately since the code selects/deselects all checkboxes on the form, it also ticks/unticks the opt in/out checkbox.
Is there a way - possibly by targeting the opt in/out checkbox’s ID - to filter it out of this mass selection/de-selection process?
I’m sure it’s pretty straightforward but as I say I’m a Javascript novice.
Thanks in advance,
Tony.