I have a problem here..
I had done drag n drop image using jquery. Then after drop, I get the xy coordinate of the image..Then a pop up message will display..inside the pop up message user can insert the name of the location they want to name..There is a save button in the pop up message. When click save, Iwant the xy coordinate and the name of the location is being inserted into sql server management. How to do that??? Do I have to use ajax http request?? Please help me!!.....
This is my code what i've done so far:
$('#dragThis').draggable({
cursor: 'move', // sets the cursor apperance
containment: '#dragThis2',
drag: function() {
var offset = $(this).offset();
var xPos = Math.abs(offset.left);
var yPos = Math.abs(offset.top);
$('#posX').text('x: ' + xPos);
$('#posY').text('y: ' + yPos);
},
stop: function(event, ui) {
// begin: you can use the code below where ever you'd like to display the popup
$('.popup').remove();
var $d = $('<div></div>')
.addClass('popup')
.html('<form method="POST" action="your_action.html"><div><label>Set a name for your location</label><div><input type="text" name="location_name" /></div></div><button type="save" class="save">Save</button><button type="button" class="cancel">Cancel</button></form>')
.appendTo(document.body)
.hide();
$d.find('button.save').click(function(e) {
e.preventDefault();
$('#dragThis').draggable('disable');
alert('Saved');
$d.remove();
});
//insert
$d.find('button.cancel').click(function(e) {
$('#dragThis').draggable('enable');
$d.remove();
});
$('#dragThis').draggable('disable');
var $win = $(window);
$d.css({ top: $win.scrollTop() + ($win.height()-$d.height())/2,
left: $win.scrollLeft() + ($win.height()-$d.width())/2,
position: 'absolute'
})
.show();
// end
}
});
// Show dropped position.
var Startpos = $("#dragThis").position();
var Stoppos = $(this).position();
$("#dragThis").val((Stoppos.left - Startpos.left));
var left = Math.abs(Stoppos.left);
var top = Math.abs(Stoppos.top);
$('#posX').text('left: ' + left);
$('#posY').text('top: ' + top);
// prompter();
//