I want to create dynamic form controls.
where textbox, radio button can drag and drop in form.
I found drag and drop at here.
[
^]
and below link exactly what I required but at here required drag and drop
http://jsfiddle.net/techbrij/uNNMr/
What I have tried:
@{
ViewBag.Title = "draganddrop3";
Layout = null;
}
<h2>draganddrop3</h2>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Droppable - Default functionality</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<style>
#box {
width: 100px;
height: 100px;
padding: 0.5em;
float: left;
margin: 10px 10px 10px 0;
}
.draggable {
float: left;
z-index: 99;
}
#droppable {
width: 300px;
height: 500px;
padding: 0.5em;
position: absolute;
left: 33%;
top: 15%;
margin: 10px;
}
</style>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$(function () {
$(".draggable").draggable();
$("#droppable").droppable({
drop: function (event, ui) {
debugger;
var draggableId = ui.draggable.attr("id");
//every time getfileldId get textbox (how can i get currend draggable id value)
if (ui.draggable.attr("id") == "textbox") {
$(this).append('<input id="Text1" type="text" />')
}
else if (ui.draggable.attr("id") == "chekbox") {
$(this).append('<input id="Checkbox1" type="checkbox" />')
}
else if (ui.draggable.attr("id") == "dropdown") {
$(this).append('<select name="dropdown">' +
'<option value="volvo">Volvo</option>' +
'<option value="saab">Saab</option>' +
'<option value="fiat">Fiat</option>' +
' <option value="audi">Audi</option>' +
' </select>')
}
}
});
});
</script>
</head>
<body>
<div id="" class="">
<ul class="draggable" id="textbox">Textbox</></ul><br />
<ul class="draggable" id="chekbox">chekbox</> </ul><br />
<ul class="draggable" id="dropdown">dropdown</></ul><br />
</div>
<div id="droppable" class="ui-widget-header">
<p>Drop here</p>
</div>
</body>
</html>