Solved

Select data from dynamically created table...

Posted on 2016-10-07
4
34 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 51

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 51

Expert Comment

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

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
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…

759 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

23 Experts available now in Live!

Get 1:1 Help Now