save position after drag item plz help me!!!!

save position after drag item plz help me!!!!

well......
i'v built a code which allows people to drag items and create a new page...
this is the html code:
  1. <section class="has-border">
  2. <div style="width: 100%; height: 1000px; background-color: lightyellow;" >
  3. <span style="font-size: <%=s1 %>; color: <%=color1 %>" id="makeitmove"><%=request.getParameter("p1")%></span> 
  4. <span style="font-size: <%=s2 %>; color: <%=color2 %>" id="makeitmove3"><%=request.getParameter("p2")%></span> 
  5. <span style="font-size: <%=s3 %>; color: <%=color3 %>" id="makeitmove4"><%=request.getParameter("p3")%></span>
  6. <%if(request.getParameter("i1")!=null)
  7.          {%>
  8. <img id="mpicture1" width=<%=width1 %> height=<%=h1 %> alt="" src=<%=im1 %>>
  9. <% }if(request.getParameter("i2")!=null) {%>
  10. <img id="mpicture2" width=<%=width2 %> height=<%=h2 %> alt="" src=<%=im2 %>>
  11. <%}if(request.getParameter("i3")!=null) {%>
  12. <img id="mpicture3" width=<%=width3 %> height=<%=h3 %> alt="" src=<%=im3 %>>
  13. <%} %>


the parameters are not matter!!!! 
this is the jquery code which allow to drag:
  1. <script>
  2. $(document).ready(function(){
  3. $("#makeitmove").draggable( {   containment: "body", scroll: false   } );
  4. $("#makeitmove1").draggable( {containment: "body", scroll: false} );
  5. $("#makeitmove2").draggable( {containment: "body", scroll: false} );
  6. $("#makeitmove3").draggable( {containment: "body", scroll: false} );
  7. $("#makeitmove4").draggable( {containment: "body", scroll: false} );
  8. $("#mpicture1").draggable( {containment: "body", scroll: false} );
  9. $("#mpicture2").draggable( {containment: "body", scroll: false} );
  10. $("#mpicture3").draggable( {containment: "body", scroll: false} );

  11. });
  12. </script>
and after that i found how o get position with percantage!!!!!:
  1. function getLeft(id)
  2. {
  3.    leftStr = $(id).css('left'),
  4.        pxPos = leftStr.indexOf('px'),
  5.        leftVal = leftStr.substr(0, pxPos),
  6.        leftPercent = (leftVal / $(window).width() * 100).toString(),
  7.        dotPos = leftPercent.indexOf('.'),
  8.        leftPercentStr = dotPos == -1 ? leftPercent + '%' : leftPercent.substr(0, dotPos) + '%';
  9.    return leftPercentStr;
  10. }
  11. function getTop(id )
  12. {
  13.    topStr = $(id).css('top'),
  14.        px1Pos = topStr.indexOf('px'),
  15.        topVal = topStr.substr(0, px1Pos),
  16.        topPercent = (topVal / $(window).height() * 100).toString(),
  17.        dot1Pos = topPercent.indexOf('.'),
  18.        topPercentStr = dot1Pos == -1 ? topPercent + '%' : topPercent.substr(0, dot1Pos) + '%';
  19.    return topPercentStr;

  20. }
now i want that right after dragging the elements their ositions will be saved o my sql:

  1. db.insertUpdateDelete("insert into position1 values( '" + getLeft("#mpicture3") + "', '" + getTop("#mpicture3") + "' )");
can anyone helo me?!?!?!?!?! plz