First, thanks to ldbtractor because the line:
Code:
//document.getElementById("vendorflag_c").onchange = function () { helped me solve my problem 
Now, here's something that might help you.
There are two things you have to change:
1) The location of
has to be in the beginning of the display() function, not at the end.
2) You have to scape the quotes (only the double ones). For example, instead of:
Code:
document.getElementById("your_field_name").onchange = function you should use:
Code:
document.getElementById(\"your_field_name\").onchange = function
Here is a example: (Please don't copy paste right away, first change the words YOUR_CHECKBOX for the name of your checkbox)
PHP Code:
public function display() {
parent::display();
echo "<script>
document.getElementById(\"YOUR_CHECKBOX\").onchange = function () {
if(document.getElementById('YOUR_CHECKBOX').checked){
alert('checked');
}else{
alert('NO - checked');
}
}
</script>";
}
Remember, if you're going to use quotes scape them.
Bookmarks