Solved

Select data from dynamically created table...

Posted on 2016-10-07
4
59 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 56

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 56

Expert Comment

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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…

696 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