what i wanted to do is when i clicked on a checkbox it will automatically appear on a certain part of the page. i tried to give a checkbox an onclick=’displayit()’/oncchange=’displayit()’ where displayit() is:
function displayit(obj){
document.divnam.write(obj.value);
}
the divnam is the name of the division where i wanted the text to appear..isnt it possible?i also tried removing the divnam and putting the function itself in the division
<div name='divnam' ><script>
function displayit(obj){document.write(obj.value);}
</script></div>
Put an
idon thedivelement instead ofnameso that you can easily access it. You use theinnerHTMLproperty to set the contents of the element:Putting the script inside the element would only work if you run the script while the page is loading. Declaring a function inside the element has no effect, it doesn’t matter where in the page the function is declared.