javascript - jquery function on textbox value change when checkboxes are checked -
i have text-area getting populated values of checkboxex being checked. want call jquery function when content of text-area changed. tried following function working when content changes via key not due checkbox value mapping.
$(document).ready(function(){ $('#message_sent_to').on('propertychange change keyup paste input',function() { alert("hello"); var limit = $('#promo_limit').val(); alert("<%= @p_limit %>"); });
the text-area is
<%= f.text_area :sent_to, :class => 'form-control'%>
there 2 checkboxes, 1 mapping value of checkbox , 1 mapping individual checkbox value.
<%= check_box_tag "contact_no[]", staff.contact_no %> <%= check_box_tag "contact_nos[]", @staff_members.map(&:contact_no).join(', ') %>
note: code checkbox mapping long, not posting here.
you can using javascript checking textbox value, i.e changed or not on basis of time.
var $message_sent_to = $("#message_sent_to"); $message_sent_to.data("value", $message_sent_to.val()); setinterval(function() { var data = $message_sent_to.data("value"), val = $message_sent_to.val(); if (data !== val) { $message_sent_to.data("value", val); alert("changed"); } },100);
Comments
Post a Comment