954,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

creation of checkbox in javascript

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.

amaravanich
Newbie Poster
12 posts since Aug 2006
Reputation Points: 10
Solved Threads: 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 /etc around them), or when you try to access 'null' elements or null returns...

Whatexactly does the error say?

MattEvans
Veteran Poster
Moderator
1,386 posts since Jul 2006
Reputation Points: 522
Solved Threads: 64
 

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

amaravanich
Newbie Poster
12 posts since Aug 2006
Reputation Points: 10
Solved Threads: 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 /etc around them), or when you try to access 'null' elements or null returns...

Whatexactly does the error say?

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

yurj
Newbie Poster
1 post since Nov 2007
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You