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.

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?

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.