You are viewing limited content. For full access, please sign in.

Question

Question

Trying to modify the values in the table using javascript but its not working.Please help

asked on February 8, 2016 Show version history

I have a table that is populated from lookup rules using table from sql database. I want to modify age to display just the number without years text.

this is the javascript i wrote, but its not working. Please help

q4 is the id of table

$(document).ready(function() {
       var re = /years/i;
      
     function modify(){       
          $('#q4 tr').each(function(){
        $(this).find('.age input').each(function() {
         var age = $(this).find('.age input').val();
         $(this).find('.age input').val(age.replace(re,''));
      });     
    
   }    
 
  modify();             
  
  
});

 

 

0 0

Replies

replied on February 12, 2016

Hi Vineela,

Try adding a class to the "Age" column by going to its advanced field options and typing a class name into the "CSS class" section (I added the class name "age"). Then try out the following JavaScript:

$(document).on('change', '.age input', function(){
  $('.age input').each(function(){
    $(this).val($(this).val().slice(0,2));
  });
});

This will keep the first two characters of the field (which should work unless someone is 100+ years old).

Let me know if this works for you!

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.