jQuery, Check if input value comes from textbox inside footer in table -
i need apply special function jquery in case input value comes textbox inside footer of table. i'm trying figure out jquery condition find out.
<tfoot> <tr> <td> <input type="text" name="desc[]" onkeyup = "inputchanged(this)"> </td> <td> <input type="text" name="duration[]" onkeyup = "inputchanged(this)"> </td> <td> <input type="text" name="start[]" class="start" onkeyup = "inputchanged(this)"> </td> <td> <input type="text" name="wait[]" onkeyup = "inputchanged(this)"> </td> <td> <input type="text" name="end[]" onkeyup = "inputchanged(this)"> </td> <td> <input type="text" name="phone[]" onkeyup = "inputchanged(this)"> </td> </tr> </tfoot>
the jquery function should go this:
<script> function inputchanged(control) { if (...) { } else { } } </script>
you can use
$('tfoot input').on('keyup', function() { inputchanged($(this).val()); });
then function inputchanged
receive value of input parameter every time input changes, don't forget remove onkeyup
attribute input html.
follow example:
var labels = $('tbody td'); $('tfoot input').on('keyup', function() { var $t = $(this); updateparagraph(labels.eq($t.parent().index()), $t.val()); }); function updateparagraph(el, value) { el.html(value); }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <table> <tbody> <tr> <td>desc</td> <td>duration</td> <td>start</td> <td>wait</td> <td>end</td> <td>phone</td> </tr> </tbody> <tfoot> <tr> <td> <input type="text" name="desc[]" /> </td> <td> <input type="text" name="duration[]" /> </td> <td> <input type="text" name="start[]" class="start" /> </td> <td> <input type="text" name="wait[]" /> </td> <td> <input type="text" name="end[]" /> </td> <td> <input type="text" name="phone[]" /> </td> </tr> </tfoot> </table>
Comments
Post a Comment