i want to save the droppable positions to a database. Within each droppable div ive added a text input field with the div name with a 'i_' prefix.
If i put an alert in the code to show the dropped object, the id is correct in the alert box and appears in the text input field. But when i click the OK , it disappears.
<div style="float:left; border-style:solid;">
<div class="draggable" class="ui-widget-content" id="1059" style="left:0px; top:0px;" >john doe</div>
<div class="draggable" class="ui-widget-content" id="1113" style="left:0px; top:0px;" >jane doe</div>
<div style="float:left; vertical-align:top" class="droppable ui-widget-header" id="1-2">
<input type='text' id='i_1-2' name='i_1-2' value=''><p>1-2</p></div>
<div style="clear:both";></div> <div style="float:left; vertical-align:top" class="droppable ui-widget-header" id="2-1">
<input type='text' id='i_2-1' name='i_2-1' value=''>
<p>2-1</p></div>
if the function that is called is this, the text box goes yellow , but the value isnt set
drop: function(event, ui )
{
var f=ui.draggable.attr("id");alert(f);
var s = 'i_'+$(this).attr("id");//alert(s);
$('#'+s).css({'background-color' : 'yellow'});
$('#'+s).val(f);
}
what am i doing wrong ?
$( ".droppable" ).droppable
({
activeClass: "ui-state-hover",hoverClass: "ui-state-active",
drop: function( event, ui )
{
var f=ui.draggable.attr("id");//alert(f);
var s = 'i_'+$(this).attr("id");
document.getElementById(s).value=f;//alert(document.getElementById(s).value);
}
} );