Solved

Select data from dynamically created table...

Posted on 2016-10-07
4
41 Views
Last Modified: 2016-10-09
Hi All,

I have a table that will be created dynamically with data.  In the first column will be a textbox with data.  I want to be able to capture when data is changed in any of the columns.  Below is the code but you can also find it in this fiddle.  https://jsfiddle.net/isogunro/sb4ohdkj/1/
<table id='Prioritize' border=1>
  <thead>
    <th>Priority Number</th>
    <th>Title</th>
    <th>Project Name</th>
    <th>Project Number</th>
  </thead>
  <tbody>
    <tr><td><input type='text' name='rowID-1' id='rowID-1' value=1></td><td>IT</td><td>Project Smart</td><td>it-34-xx</td></tr>
    <tr><td><input type='text' name='rowID-2' id='rowID-2' value=1></td><td>IT</td><td>Project Smart</td><td>it-34-xx</td></tr>
    <tr><td><input type='text' name='rowID-3' id='rowID-3' value=1></td><td>IT</td><td>Project Smart</td><td>it-34-xx</td></tr>
    <tr><td><input type='text' name='rowID-4' id='rowID-4' value=1></td><td>IT</td><td>Project Smart</td><td>it-34-xx</td></tr>
    <tr><td><input type='text' name='rowID-5' id='rowID-5' value=1></td><td>IT</td><td>Project Smart</td><td>it-34-xx</td></tr>
    <tr><td><input type='text' name='rowID-6' id='rowID-6' value=1></td><td>IT</td><td>Project Smart</td><td>it-34-xx</td></tr>    
  </tbody>
</table>

Open in new window


$('#rowID-*').change(function () {
    alert($('#rowID-*').val());    
});

Open in new window

https://jsfiddle.net/isogunro/sb4ohdkj/1/
0
Comment
Question by:Isaac
  • 2
4 Comments
 
LVL 9

Assisted Solution

by:Brian Tao
Brian Tao earned 250 total points
ID: 41834603
Change your javascript to the following:
$('table#Prioritize').on('change','input[type=text]',function(e){
    alert($(this).val());
});

Open in new window

0
 
LVL 52

Accepted Solution

by:
Julian Hansen earned 250 total points
ID: 41834728
This will do it as well
$('tr td:first-child input').change(function () {
    alert($(this).val());    
});

Open in new window

If you want to specifically target that table
$('#Prioritize tr td:first-child input').change(function () {
    alert($(this).val());    
});

Open in new window

0
 
LVL 5

Author Closing Comment

by:Isaac
ID: 41835460
Thanks!
0
 
LVL 52

Expert Comment

by:Julian Hansen
ID: 41835602
You are welcome.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now