INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Disable dynamically generated input type = checkbox in table column

Disable dynamically generated input type = checkbox in table column

Disable dynamically generated input type = checkbox in table column

(OP)
I am working on a JavaScript function to disable all the dynamically generated html checkboxes in a table column. The little test function that I have works fine, but I need to be able to loop through and disable. It takes a paramter 'month' which is a number. The 'chk_xxx_month' is the dynamically generated id of the checkbox. The xxx is the id from the first column of a datatable. How do I write the JavaScript to disable all checkboxes with the month? Here is my JavaScript code.

function SelectAllProducts(month) {
if (document.getElementById("chk_0_" + month).checked) {
var chkBoxes
document.getElementById("chk_1309_" + month).disabled = true
document.getElementById("chk_1309_" + month).checked = false
document.getElementById("chk_1308_" + month).disabled = true
document.getElementById("chk_1308_" + month).checked = false
document.getElementById("chk_1307_" + month).disabled = true
document.getElementById("chk_1307_" + month).checked = false
} else {
document.getElementById("chk_1309_" + month).disabled = false
document.getElementById("chk_1308_" + month).disabled = false
document.getElementById("chk_1307_" + month).disabled = false
}

Thanks in advance.

RE: Disable dynamically generated input type = checkbox in table column

(OP)
Forgot to mention that the first row checkboxes will be clicked to enable/disable checkboxes.

RE: Disable dynamically generated input type = checkbox in table column

And what is or is not happening?

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum

RE: Disable dynamically generated input type = checkbox in table column

(OP)
I managed to solve that problem. Problem now is my validate function for this issue. The function Validate() calls the return of Y or N, based on whether a checkbox is checked or not. Even though the column has a checked checkbox (returns 'Y'), function still shows the alert. I'm an asp.net developer and I have to do a part of this in ASP classic, which I know nothing about. Why won't my function work? Also receiving a message that says "undefined'.

function AnyChecked(month) {
if(! document.getElementById("chk_0_" + month).checked
&& ! document.getElementById("chk_1309_" + month).checked
&& ! document.getElementById("chk_1308_" + month).checked
&& ! document.getElementById("chk_1307_" + month).checked
&& ! document.getElementById("chk_1306_" + month).checked
&& ! document.getElementById("chk_1305_" + month).checked
&& ! document.getElementById("chk_1304_" + month).checked
&& ! document.getElementById("chk_1303_" + month).checked
&& ! document.getElementById("chk_1301_" + month).checked
&& ! document.getElementById("chk_1302_" + month).checked
&& ! document.getElementById("chk_1299_" + month).checked
&& ! document.getElementById("chk_1300_" + month).checked
&& ! document.getElementById("chk_1296_" + month).checked
&& ! document.getElementById("chk_1297_" + month).checked
&& ! document.getElementById("chk_1298_" + month).checked
&& ! document.getElementById("chk_1295_" + month).checked
) {
return 'N'
} else {
return 'Y'
}
}

function Validate() {
anySelected = 'N';
for (i = 1; i < 13;i++)
{
anySelected = AnyChecked;
if (anySelected = 'N')
{
alert('Need to Select a capsule');
return false;
}
else
{
return true;
}
}
}

RE: Disable dynamically generated input type = checkbox in table column

Hi

Quote (sirnose1)

if (anySelected = 'N')
Are you sure there you need assignment and not equality check ?

Feherke.
feherke.ga

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close