how to create "add" javascript function using existing "delete" function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • driveman
    New Member
    • Jul 2010
    • 2

    how to create "add" javascript function using existing "delete" function

    Hello,
    I have existing code working perfectly, which can :
    -clone existing datas (title, textarea, link-to-picture) contained in xml file, and :
    -delete datas.

    I looking for a javascript code to "Create" the first data sample, because "clone" uses the last datas in the .xml file, and obviously is not proper if xml file is empty.

    Here is my code.
    Code:
     
    <script type="text/javascript">
    
    function removeDiv(id)
    {
    $("#"+id).fadeOut("slow");
    $("#"+id).remove();
    }
    
    function cloneIt(cloneId) {
    var currentDiv = $("#"+cloneId).parent(".item");
    var Id = $(currentDiv).attr("id").match(/[0-9]+/gi);
    var nextId = parseInt(Id,10) + 1;
    $.get("'._MODULE_DIR_.$this->name.'/ajax.php?id="+nextId, function(data) {$(currentDiv).after(data);});
    $("#"+cloneId).remove();
    }
    
    //This is what I'd like to do:
    function createIt() {
    ???
    }
    </script>
    I can provide the php file if someone has an idea.
    Thanks in advance.
  • RamananKalirajan
    Contributor
    • Mar 2008
    • 608

    #2
    Hi,
    Are you looking for this.

    Thanks and Regards
    Ramanan Kalirajan

    Comment

    • driveman
      New Member
      • Jul 2010
      • 2

      #3
      Hi,
      Not at all Ramanan.
      Your example is simply for inserting and deketing a row.
      Too simple Ramanan!

      Mine is to clone or delete some information included in an xml file and updated by another function.

      Thanks anyway Ramanan!

      Comment

      Working...