0

Hi all,
I have to create a check box in javascript i just created the checkbox field and called a function in onclick.but onclick event is not firing.i'm getting an error indicating that chkbox has no properties.i have to fire an event on click this checkbox can anyone please help me in resolving the problem here i'm sending my code part.
var cellText=document.createElement("input");
cellText.type="checkbox";
//cellText.align="right"
cellText.name="chkbox"
cellText.onClick="return changestatus(this,this.parentNode,document.form_enc);"
please help me i'm not getting nay rference to sort out this issue
Thanking you in adavance
vani.

3
Contributors
3
Replies
4
Views
10 Years
Discussion Span
Last Post by yurj
0

try changing:

cellText.onClick="return changestatus(this,this.parentNode,document.form_enc);"

to:

cellText.onclick=function(){return changestatus(this,this.parentNode,document.form_enc);};

That's a weird error message though... You tend to get that error (in firefox) when you try and access html elements out of context (i.e. without a <html><body> /etc around them), or when you try to access 'null' elements or null returns...

What exactly does the error say?

0

Hi MattEvens
Thank You very much.i did the changes as u specified.Its working fine.
once again thanku Matt.

0

try changing:

cellText.onClick="return changestatus(this,this.parentNode,document.form_enc);"

to:

cellText.onclick=function(){return changestatus(this,this.parentNode,document.form_enc);};

That's a weird error message though... You tend to get that error (in firefox) when you try and access html elements out of context (i.e. without a <html><body> /etc around them), or when you try to access 'null' elements or null returns...

What exactly does the error say?

I confirm that theelement.onclick= function() { return myfunction() }; works for dinamically generated element both in explorer and firefox

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.