Solved

Select data from dynamically created table...

Posted on 2016-10-07
4
48 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 54

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 54

Expert Comment

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

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
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…

831 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