Posted By

BoNzO on 03/16/09


Tagged

javascript edit inline


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

pezland


Inline edit


 / Published in: JavaScript
 

  1. var stat = false;
  2.  
  3. function edit(id, txt){
  4. txt = typeof(txt) != 'undefined' ? txt : 'Salva';
  5. var el = document.getElementById(id);
  6. if(!stat){
  7. var cmd = '<br /><input type="submit" value="'+ txt +'" onclick="save(\''+ id +'\')" />';
  8. el.innerHTML = '<textarea cols="100%" rows="8%" id=\"edit-'+ id +'\">' + el.innerHTML + '</textarea>' + cmd;
  9. stat = true;
  10. }
  11. }
  12.  
  13. function save(id){
  14. var elm = document.getElementById(id);
  15. var rep = document.getElementById('edit-'+ id);
  16. var str = rep.value;
  17. elm.innerHTML = str;
  18. stat = false;
  19. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: vigneshwaran on March 16, 2009

hjgffghfj,gjhgfjhfgjf

You need to login to post a comment.