tags:

views:

24

answers:

1

i want to have a table of select dropdowns and when you click "commit" all of the selects will simply be regular text inside the of the table. do i have to put the select inside of a div and remove and replace with raw html?

+3  A: 

You could merely replace each select with the text-version of their present value:

$(function(){ 
  // user clicks any 'commit' button
  $(".commit").click(function(){ 
    // find all select menus in same table-row
    $(this).closest("tr").find("select").each(function(){ 
      // convert to regular text
      $(this).replaceWith( $(this).val() ); 
    }); 
  }); 
});

Online example: http://jsbin.com/oleda

Jonathan Sampson