hi,
i'm a new user of Jquery and i'm trying to make a drag and drop system with a list of products ( to drag) and a calendar with hours ( drop zone) .
the problem is that i'm new with this technology and i don't know how can i put the name of the product which is written in the drag zone into the drop zone.
my js code is like, and i know it's false because i use a global variable "monproduit" into a function but i don't know how can i pass this variable because i can t find the call of the function:
- <?php
if(!isset($_SESSION["isConnected"])||$_SESSION['isConnected']!=1)
die();
?>
<link type="text/css" href="datepicker/css/ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="datepicker/ui.core.js"></script>
<script type="text/javascript" src="datepicker/ui.datepicker.js"></script>
<script type="text/javascript" src="datepicker/ui.draggable.js"></script>
<script type="text/javascript" src="datepicker/ui.droppable.js"></script>
<script type="text/javascript">
$(function() {
$("#datepicker").datepicker();
});
var monproduit= {nom:'',id:1};
$(function() {
$("span.zone_drag").draggable({
cursor: 'move',
helper: function(event)
{
return $('<div class="ui-widget-header">Mon objet</div>');
}
monproduit.nom=$(this).html();
});
});
$(function() {
$("span.zone_drop").droppable({
drop: function(event, ui)
{
$(this).addClass('ui-state-highlight').html(monproduit.nom);
}
});
});
</script>
<?php
$page='
<div id="v_produit">
<div id="datepicker"></div>
<div id="draggable" class="ui-widget-content">
<span class="zone_drag">
PS3
</span>
</div>
<div id="draggable" class="ui-widget-content">
<span class="zone_drag">
Xbox 360
</span>
</div>
</div>
<div id="v_vente">
<table>
<th>10h</th><th>11h</th><th>12h</th><th>13h</th>
<tr>';
$h=10;
$demi='';
while ($h<14)
{
$page.='
<td>
<div id="droppable" class="ui-widget-header">
<span id='.$h.$demi.' class="zone_drop">'.$h.'h'.$demi.'</span>
</div>
</td>';
$h++;
if ($h==14 and $demi=='')
{
$demi='30';
$h=10;
$page.='</tr><tr>';
}
}
$page.='
</tr>
</table>
$page.='</div>';
echo $page;
?>