我有一个创建动态标签的脚本,但我的问题是如何在标签上添加最大值?我希望有人可以帮助我。
迎接
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script>
<script type="text/javascript">
var countBox = 1;
function toevoegen() {
document.getElementById('labels_span').innerHTML+='<span id="labelnaam'+countBox+'">Labelnaam:<input type="text" name="label_naam['+countBox+']"/></span';
document.getElementById('labels_span').innerHTML+='<span id="labelomschrijving'+countBox+'"><br/>Labelomschrijving:<input type="text" name="label_omschrijving['+countBox+']"/></br></br></span>';
document.getElementById('labels_span').innerHTML+='<span id="button'+countBox+'" ><input type="button" value="verwijderen" onclick=\'verwijderen('+countBox+');\'></br></br></span>';
countBox += 1;
}
function verwijderen(countBox) {
var label1 = "#labelnaam"+countBox;
var label2 = "#labelomschrijving"+countBox;
var label3 = "#button"+countBox;
$(label1).remove();
$(label2).remove();
$(label3).remove();
countBox -= 1;
}
</script>
<form action='' name='' method='post'>
</br><h4>Label toevoegen<input type='button' value='toevoegen' onclick='toevoegen();'></h4></br>
<div id='labels_span'></div></br>
</br><input type='submit' value='Registreren' name='submit_registreren'>
</form>
答案 0 :(得分:0)
检查countbox
equal/greater/greater than
是否为function toevoegen() {
if (countBox > 3) { //can use >=, > or ==
return;
}
document.getElementById('labels_span').innerHTML+='<span id="labelnaam'+countBox+'">Labelnaam:<input type="text" name="label_naam['+countBox+']"/></span';
document.getElementById('labels_span').innerHTML+='<span id="labelomschrijving'+countBox+'"><br/>Labelomschrijving:<input type="text" name="label_omschrijving['+countBox+']"/></br></br></span>';
document.getElementById('labels_span').innerHTML+='<span id="button'+countBox+'" ><input type="button" value="verwijderen" onclick=\'verwijderen('+countBox+');\'></br></br></span>';
countBox += 1;
}
到某个金额,例如
function verwijderen(count) {
var label1 = "#labelnaam"+count;
var label2 = "#labelomschrijving"+count;
var label3 = "#button"+count;
$(label1).remove();
$(label2).remove();
$(label3).remove();
countBox -= 1;
}
并将删除功能更改为:
countBox
您正在将verwijderen
传递给countBox
,然后隐藏功能中的TIMESTAMP(6) WITH LOCAL TIME ZONE
变量