Click here to Skip to main content
15,909,530 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

Here is my problem i am creating html controls dynamically so now i try to add events to my control can any one help me ..

here the sample code..

C#
var cellfour = row.insertCell(3);
  var el = document.createElement('select');
   el.name = 'select' + iteration;
  el.id = 'select' + iteration;

//here i like to add onchange event but it wont works 

 el.onchange=" return alert('hi')";
  cellfour.appendChild(el);

 arr=["Input","Select","CheckBox","Radio"];
  for ( i=0;i<arr.length;i++)
  {
  var opt1=document.createElement('option');
  opt1.text=arr[i];
  el.options.add(opt1);




Thanks in Advance..

Seshu
Posted
Updated 18-May-11 22:36pm
v3

1 solution

Take a look at addEventListener and attachEvent: here[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900