Click to See Complete Forum and Search --> : A simple question


Lily
04-05-2003, 01:51 AM
A simple question about get the 'type' vaule of checkbox object.

...
<SCRIPT LANGUAGE="JavaScript">
function delItem()
{
if(document.getElementById(checkboxName).checked == true)
{
document.getElementById(checkboxName).type="hidden";
return true;
}
}
.....

A error appers, remand me that "could not get the type property.This command is not supported". I don't know why.

What I want is delete the check box object from the page when click it. Are there some methods can delete it directly? Thanks in advance!
:confused:

Lily

AdamGundry
04-05-2003, 02:55 AM
The type property is read-only, so you cannot dynamically change a form element from one type to another. You can, however, hide it from the user by setting either display or visibility:

document.getElementById(checkboxName).style.display = 'none';
or
document.getElementById(checkboxName).style.visibility = 'hidden';

If you set display: none, the element will not take up space, wherease if you set visibility: hidden it will still take up space but be invisible.

Hope this helps

Adam

Lily
04-05-2003, 05:54 AM
Adam,

Thanks for your help!

A good forum and many friendly friends. :)


Lily