Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disable dynamically generated input type = checkbox in table column

Status
Not open for further replies.

sirnose1

Programmer
Nov 1, 2005
133
0
16
US
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.
 
Forgot to mention that the first row checkboxes will be clicked to enable/disable checkboxes.
 
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
 
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;
}
}
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top