javascript - How can I get the value from a series of textbox with same id -


i have series of textboxes same name

<%for(i=0;i<=nooftasks;i++){%> <input type="text" id="duration" name="duration" class="td4" onkeyup="durationformat()"> }%> 

in javascript have add colon after 2 digits

function durationformat() {     var duration = document.getelementsbyname("duration").value;     if(duration.length==2){         duration=duration+":";     } } 

but not desired result not string textbox of particular text box.

any ideas?

 <input type="text" id="duration" name="duration" class="td4" onkeyup="durationformat(this)"> <script>  function durationformat(obj) {      if ((obj.value.length)== 2) {          obj.value+=":";      }   } </script> 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -