setAttribute property in javascript
-
SamRST wrote:
// txtC.setAttribute("onClick","alert('Ok')");//this is not working
Chage it...
txtC.onClick = function MyClick() {alert('Ok');}
Hi, Hope u ll get it.Thanks, Sun Rays To get something you must have to try once. My Articles
modified on Friday, May 9, 2008 1:38 AM
-
use the following txtC.Attributes.Add("onClick", "javascript:alert('Ok')");
.....
-
hi.. i'm creating textboxes and imgebttn dynamically inside a table using javascript. i set some properties for the textboxes. but how can i bind 'onclick' events to the button. The code i used is below. //for textbox var txtA=document.createElement("input"); txtA.type = 'text'; txtA.id ='a'+lastrowIndex; txtA.name ='a'+lastrowIndex; txtA.className='textbox'; txtA.readonly='readonly'; //for imgbtn var txtC=document.createElement("img"); txtC.id ='c'+lastrowIndex; txtC.name ='c'+lastrowIndex; txtC.className='images_del'; txtC.src="Images/delete_16x16.gif"; // txtC.setAttribute("onClick","alert('Ok')");//this is not working Thanks in advance.
What's wrong with txtC.onclick = "alert('OK');" ???
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
What's wrong with txtC.onclick = "alert('OK');" ???
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
I believe it's meant to be all lowercase
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
I believe it's meant to be all lowercase
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
what all i tried is. txtC.setAttribute("onClick","alert('Ok')"); txtC.setAttribute("onclick","alert('Ok')"); txtC.setAttribute("onClick", "javascript:alert(this.id);"); txtC.setAttribute("onclick", "javascript:alert(this.id);"); txtC.onClick = "javascript:alert(this.id);"; txtC.onclick = "javascript:alert(this.id);"; txtC.onclick = "javascript:alert('Ok');";
-
what all i tried is. txtC.setAttribute("onClick","alert('Ok')"); txtC.setAttribute("onclick","alert('Ok')"); txtC.setAttribute("onClick", "javascript:alert(this.id);"); txtC.setAttribute("onclick", "javascript:alert(this.id);"); txtC.onClick = "javascript:alert(this.id);"; txtC.onclick = "javascript:alert(this.id);"; txtC.onclick = "javascript:alert('Ok');";
Has to use event handler ... txtC.onclick=doSomething; function doSomething(e) { alert('Ok'); }
.....
-
Has to use event handler ... txtC.onclick=doSomething; function doSomething(e) { alert('Ok'); }
.....
-
Thanks You So much my lovely GUY... Its Worked... Great work.. Dear... i used ... txtC.onclick = function(){ImageId(this.id);}; function ImageId(i) { alert(i); }
Cheers :)
.....
-
what all i tried is. txtC.setAttribute("onClick","alert('Ok')"); txtC.setAttribute("onclick","alert('Ok')"); txtC.setAttribute("onClick", "javascript:alert(this.id);"); txtC.setAttribute("onclick", "javascript:alert(this.id);"); txtC.onClick = "javascript:alert(this.id);"; txtC.onclick = "javascript:alert(this.id);"; txtC.onclick = "javascript:alert('Ok');";
have you tried this var ele = document.getElementById('abc'); ele.onclick = showalert; function showalert() { alert('a'); } -------------------- Check my other javascript posts
Regards, Webtips - Web Development tips