这是我的代码,当我点击添加按钮时,新的文本字段即将到来,但总页面正在刷新,现有数据也在刷新,请帮助我。
<?php
if( !isset( $_POST['j'] ) ) {
static $j = 1;
} else {
//j is a reference for $i in the loop. $i will loop while it is less than $j.
if( isset( $_POST['plus'] ) ) {
$j = $_POST['j']+1; //by incrementing $j, $i will loop one more time.
}
if( isset( $_POST['minus'] ) ) {
if( @$j < 1 ) { //if there is only one box the user can't remove it
$j = $_POST['j']-1;
}
}
}
?>
<?php echo '<input type="hidden" name="j" value="' . @$j . '"/>' ?>
<?php for( $i = 0; $i < @$j; $i++ ) { ?>
<input id="txt_id" name="txt_id[]" type="text" value="" readonly="readonly"/>
<? } ?>
<input type ="submit" value="+" name="plus">
<input type ="submit" value="-" name="minus">