Sunday, May 3, 2015

Get the id of input on keyup


 <script>   
   function myFunction(val)  
   {  
     var id = val.getAttribute('id');  
     alert("The input value has changed. The id of input is "+ id);  
   }  
 </script>  
 In this line i have dynamically generated the input according to length of the array.  
 <input style="width: 90%;" type="text" required="" name="mac[]" id="mac_<?php echo $i;?>" onkeyup="myFunction(this)" />  
 If you have fixed number of inputs then use this code  
 <input style="width: 90%;" type="text" required="" name="mac[]" id="mac" onkeyup="myFunction(this)" />   

No comments:

Post a Comment