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:
- <section class="has-border">
- <div style="width: 100%; height: 1000px; background-color: lightyellow;" >
- <span style="font-size: <%=s1 %>; color: <%=color1 %>" id="makeitmove"><%=request.getParameter("p1")%></span>
- <span style="font-size: <%=s2 %>; color: <%=color2 %>" id="makeitmove3"><%=request.getParameter("p2")%></span>
- <span style="font-size: <%=s3 %>; color: <%=color3 %>" id="makeitmove4"><%=request.getParameter("p3")%></span>
- <%if(request.getParameter("i1")!=null)
- {%>
- <img id="mpicture1" width=<%=width1 %> height=<%=h1 %> alt="" src=<%=im1 %>>
- <% }if(request.getParameter("i2")!=null) {%>
- <img id="mpicture2" width=<%=width2 %> height=<%=h2 %> alt="" src=<%=im2 %>>
- <%}if(request.getParameter("i3")!=null) {%>
- <img id="mpicture3" width=<%=width3 %> height=<%=h3 %> alt="" src=<%=im3 %>>
- <%} %>
the parameters are not matter!!!!
this is the jquery code which allow to drag:
- <script>
- $(document).ready(function(){
- $("#makeitmove").draggable( { containment: "body", scroll: false } );
- $("#makeitmove1").draggable( {containment: "body", scroll: false} );
- $("#makeitmove2").draggable( {containment: "body", scroll: false} );
- $("#makeitmove3").draggable( {containment: "body", scroll: false} );
- $("#makeitmove4").draggable( {containment: "body", scroll: false} );
- $("#mpicture1").draggable( {containment: "body", scroll: false} );
- $("#mpicture2").draggable( {containment: "body", scroll: false} );
- $("#mpicture3").draggable( {containment: "body", scroll: false} );
- });
- </script>
and after that i found how o get position with percantage!!!!!:
- function getLeft(id)
- {
- leftStr = $(id).css('left'),
- pxPos = leftStr.indexOf('px'),
- leftVal = leftStr.substr(0, pxPos),
- leftPercent = (leftVal / $(window).width() * 100).toString(),
- dotPos = leftPercent.indexOf('.'),
- leftPercentStr = dotPos == -1 ? leftPercent + '%' : leftPercent.substr(0, dotPos) + '%';
- return leftPercentStr;
-
- }
- function getTop(id )
- {
- topStr = $(id).css('top'),
- px1Pos = topStr.indexOf('px'),
- topVal = topStr.substr(0, px1Pos),
- topPercent = (topVal / $(window).height() * 100).toString(),
- dot1Pos = topPercent.indexOf('.'),
- topPercentStr = dot1Pos == -1 ? topPercent + '%' : topPercent.substr(0, dot1Pos) + '%';
- return topPercentStr;
-
- }
now i want that right after dragging the elements their ositions will be saved o my sql:
- db.insertUpdateDelete("insert into position1 values( '" + getLeft("#mpicture3") + "', '" + getTop("#mpicture3") + "' )");
can anyone helo me?!?!?!?!?! plz