我在点击按钮时动态添加一组输入
var objTo = document.getElementById('list');
var divtest = document.createElement("div");
divtest.innerHTML = '<input type="text" name="list[]"> Assign to:<select name="assign[]"><option>Select Email</option><?php $sel=mysql_query("SELECT * FROM `projectusers` WHERE `projectid`='$id'");while($se=mysql_fetch_array($sel)){ ?> <option><?php echo $se['useremail']; ?></option> <?php } ?> </select> Due date: <input class="m-wrap m-ctrl-medium date-picker" size="16" type="date" value="12-02-2012" name="due[]"><br/>';
objTo.appendChild(divtest)
但它没有在添加的输入上显示日历。
答案 0 :(得分:0)
使用此
var i=3;
var objTo = document.getElementById('list');
var divtest = document.createElement("div");
divtest.innerHTML = '<input type="text" name="list[]"> Assign to: <select name="assign[]"><option>Select Email</option><?php $sel=mysql_query("SELECT * FROM `projectusers` WHERE `projectid`='$proid'");while($se=mysql_fetch_array($sel)){ ?> <option><?php echo $se['useremail']; ?></option> <?php } ?> </select> Due date: <input class="m-wrap m-ctrl-medium date-picker" size="16" type="date" placeholder="Date" name="due[]" id="datepicker'+i+'" onclick="$(this).datepicker();"><hr/><input type="hidden" id="a">';
objTo.appendChild(divtest)
$('#datepicker'+i).click();
$('.date-picker').click();
};