By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,466 Members | 1,138 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,466 IT Pros & Developers. It's quick & easy.

accessing values of dynamic textbox in JavaScript

P: 2
am using following code to generate textboxes dynamically.
textbox fields have the same name and id. i am going to add two textbox values in onblur event by using document.getElementById('textboxname').value
but it is taking only the first row values.
i want a solution like it works for all the rows?
plese help me ,thanks in advance


Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.  
  3. function Add(id,nu)
  4. {    
  5.  
  6.     <%
  7.     for(int i=0;i<5;i++){%>
  8.     var table=document.getElementById(id);
  9.     var tbody=table.getElementsByTagName('TBODY')[0];
  10.     var newrow=tbody.appendChild(tbody.getElementsByTagName('TR')[0].cloneNode(true));
  11.  
  12.     newrow.getElementsByTagName('INPUT')[0].value='';
  13.  
  14.  
  15.     <%}%>
  16. }
  17. </script>
Apr 19 '12 #1

✓ answered by Dormilich

textbox fields have the same name and id. i am going to add two textbox values in onblur event by using document.getElementById('textboxname').value
but it is taking only the first row values.
of course. IDs have to be unique. hence you canít get more than one element via ID.

Share this Question
Share on Google+
1 Reply


Dormilich
Expert Mod 5K+
P: 8,639
textbox fields have the same name and id. i am going to add two textbox values in onblur event by using document.getElementById('textboxname').value
but it is taking only the first row values.
of course. IDs have to be unique. hence you canít get more than one element via ID.
Apr 19 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.