Is there a way in HTML to drag and drop elements from one div to another div's textbox?
In the image above, we can see Div1 and Div2. I need to drag text/words from Div1 and drop them into the TEXT BOX in Div2.
How can I implement this functionality in an HTML page for my project?
EDIT :: 18_7_2014
After following Pranav's solution, my updated code is shown below:
<head>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js"></script>
<script>
$(document).ready(function() {
$(".draggable").draggable({
revert: true,
helper: 'clone',
start: function(event, ui) {
$(this).fadeTo('fast', 0.5);
},
stop: function(event, ui) {
$(this).fadeTo(0, 1);
}
});
$("#droppable").droppable({
drop: function(event, ui) {
this.value = $(ui.draggable).text();
}
});
});
</script>
</head>
<body>
<div id="sub_cag" style="display:none; margin-left:35px; margin-top:25px; font-family:Arial, Helvetica, sans-serif;">
<span class="draggable" >sub</span><br>
<span class="draggable" >sub</span><br>
<span class="draggable" >sub</span><br>
<span class="draggable" >sub</span><br>
<span class="draggable" >sub</span><br>
<span class="draggable" >sub</span><br>
</div>
<div id="droppableHolder" style=" height:400px; width:580px; margin:10px; ">
<div style="height: 250px; width:580px; margin:0px;">
<div style=" height:60px; width:250px; margin-top:50px; float:; margin-left:0px;">
<label for="departmant_name" style="margin-left:0px; font-size: 12px;;font-weight:500;font-family:Arial, Helvetica, sans-serif;">Department Name</label>
<input type="text" maxlength="25" id="droppable" style="width:200px;float:left;font-size: 12px;font-size: 12px;height: 15px; border-radius:5px; border: solid #dddddd 2px; font-size:12px;">
</div>
<div style=" height:60px; width:250px; margin-top:0px; float:left; margin-left:0px;">
<label for="discription" style="margin-left:0px; font-size: 12px;;font-weight:500;font-family:Arial, Helvetica, sans-serif;">Discription</label>
<input type="text" maxlength="25" id="droppable" style="width:200px;font-size: 12px;font-size: 12px;height: 40px; border-radius:5px; border: solid #dddddd 2px; font-size:12px;">
</div>
<div style=" height:60px; width:220px; margin-top:-60px; float:right; margin-left:0px;">
<label for="sub_department" style="margin-left:0px; font-size: 12px;;font-weight:500;font-family:Arial, Helvetica, sans-serif;">Sub Department</label>
<input type="text" maxlength="25" id="droppable" style="width:200px;font-size: 12px;font-size: 12px;height: 15px; border-radius:5px; border: solid #dddddd 2px; font-size:12px;">
<button value="ADD" style="height:20px; width:40px; margin-top:px;"> </button>
</div>
</body>
When the browser tries to execute the line $(document).ready(function()), it generates an error with message "$ is not defined."