<div class="control-group">
<label class="control-label" for="inputgaveabonnement">
Gaveabonnement <b>*</b>
</label>
<div class="controls">
<div class="fieldrow_horz">
<div class="fieldgroup">
<label>
Gaveabonnement tekst <b>*</b>
</label>
</div>
<div class="fieldgroup">
<label>
utm_source <b>*</b>
</label>
</div>
</div>
// Save to array so that we can loop it out later =)
$result = db2_getsub( array('campaigns_id' => $this_id) );
if (!is_null($result))
{
$numsub = 0;
while ( $row = $result->fetch_object() )
{
$numsub = $numsub +1;
array_push($arrFornavn, $row->sub_name);
array_push($arrEtternavn, $row->sub_code);
}
$formcountfld=$numsub;
}
else
{
$numsub=1;
$formcountfld=1;
}
$i = 1;
if (1==1) {
for ($i = 1; $i <= $numsub; $i++)
{
?>
<div class="fieldrow_horz">
<div class="fieldgroup">
<input type="text" id="fornavn_<?= $i ?>" name="fornavn_<?= $i ?>" value="<?= $arrFornavn[$i-1] ?>" />
</div>
<div class="fieldgroup">
<input type="text" id="etternavn_<?= $i ?>" name="etternavn_<?= $i ?>" value="<?= $arrEtternavn[$i-1] ?>" />
</div>
</div>
<?php
}
} else {
?>
<div class="fieldrow_horz">
<div class="fieldgroup">
<input type="text" id="fornavn_<?= $i ?>" name="fornavn_<?= $i ?>" value="" />
</div>
<div class="fieldgroup">
<input type="text" id="etternavn_<?= $i ?>" name="etternavn_<?= $i ?>" value="" />
</div>
</div>
<?php
}
?>
<?php
$thisId = "countfld";
$thisVar = $formcountfld;
?>
<input type="hidden" name="<?= strtolower($thisId) ?>" class="input-medium" id="input<?= $thisId ?>" value="<?= htmlspecialchars($thisVar, ENT_QUOTES) ?>" />
<p>
<a href="#" id="linkAdd">+ Legg til flere</a>
</p>
</div>
</div>
</div>
$(document).ready(function(){
$("#linkRemove").click(function(){
$("#fornavn_<?= $i ?>").remove();
$("#etternavn_<?= $i ?>").remove();
});
});
如果有人可以帮助提前通过循环添加文本框,我如何删除文本框?