I wanted to know how can we retrieve the type of the element with the tag name I am creating a code on a HTML form. There are all types of HTML input elements (textfield, button, datepicker).
What I want is that if the user selects a option from a drop down, disable the checkboxes. But the checkbox are generated using PHP loop and I have also passed id in the checkbox name, so I cannot use:
document.getElementsByName('checkbox');
The name of my checkbox is "checkbox", so i tried using:
document.getElementsByTagName('input');
which i for disabling the checkbox but this disabled all the input element on the page. Is there any solution for this? How I could use the type attribute with it as checkbox and disable on checkbox:
function disabler()
{
checkboxes = document.getElementsByTagName('input');
if(checkboxes.type='checkbox')
{
for(var i=1, n=checkboxes.length;i<n;i++)
{
checkboxes[i].disabled = true;//here i want to disable only the checkbox on page
}
}
}