this is the javascript code:
- Code: Select all
<script type="text/javascript" src="javascript/view.js"></script>
<script type="text/javascript" src="javascript/prototype.js"></script>
<script type="text/javascript" src="javascript/effects.js"></script>
<script type="text/javascript" src="javascript/dragdrop.js"></script>
<script type="text/javascript">
var myStartEffect = function(element) {
element._opacity = Element.getOpacity(element);
new Effect.Opacity(element, {duration:0.2, from:element._opacity, to:0.7});
new Effect.Highlight(element, {});
}
</script>
<script type="text/javascript">
function addfield(){
var parent = document.getElementById('myDiv');
var numEle = document.getElementById('theValue');
var num = numEle.value = parseInt(numEle.value, 10)+1;
var newdiv = cE('li', {
id: "my"+num+"Div"
});
newdiv.appendChild(
cE('input', {
type: "text",
class: "element text medium",
name: "firstName"+num,
value: ""
}));
parent.appendChild(newdiv);
Sortable.create('mainlist', {starteffect: myStartEffect});
}
function cE(ele, attributes){
var el = document.createElement(arguments[0]);
if(attributes)
for( var x in attributes )
el.setAttribute(x, attributes[x]);
return el;
}
</script>
this is the html body code:
- Code: Select all
<input type="hidden" value="0" id="theValue" />
<a href="javascript:;" onclick="addfield('');">Text</a>
<ul id="mainlist">
<li id="li_8" >
<label class="description">Drop Down </label>
<div>
<select class="element select medium" id="element_8" name="element_8">
<option value="" selected="selected"></option>
<option value="1" >First option</option>
<option value="2" >Second option</option>
<option value="3" >Third option</option>
</select>
</div>
</li>
<li id="li_7" >
<input type="text" name="firstname">
</li>
<div id="myDiv"></div>
</ul>
<script type="text/javascript" charset="utf-8">
Sortable.create('mainlist', {starteffect: myStartEffect});
</script>
li_7 and li_8 have drag and drop ability but when i create a new list item via DOM it hasn't drag and drop ability...can anyone help me????



