我有一个使用 jquery/Ajax 来更新我的数据库而无需刷新的表单。jquery 在提交时淡出单选选项,然后显示另一个按钮,以防用户想要更改他们的选择。
我的问题是,一旦用户提交他们的决定,如果他们点击“改变主意”按钮,jquery 会为下面的所有实例带回收音机。
那个“改变主意”按钮怎么能只为那个实例带回收音机呢?很抱歉复杂的场景和代码块。如果您需要更多信息或解释,请询问!
谢谢。
<? $result = $mysqli->query("SELECT * FROM items WHERE Job='$job'") or die(mysqli_error($mysqli));
while( $row = $result->fetch_assoc() ){ ?>
<div class='tile'>
<script type="text/javascript">
$('document').ready(function(){
$('#form<?= $row['Id'] ?>').ajaxForm({
target: '#preview<?= $row['Id'] ?>',
success: function() {
$('#formbox<?= $row['Id'] ?>').fadeOut('slow'),
$('#preview<?= $row['Id'] ?>').fadeIn('slow');
$("button").click(function () {
$("#preview<?= $row['Id'] ?>").fadeOut("slow"),
$("#formbox<?= $row['Id'] ?>").fadeIn("slow");});
}
});
});
</script>
<div class='details'>
<div id='radios' style='position:relative; height:25px;'>
<div id="preview<?= $row['Id'] ?>" style="width:258px; margin-left:-129px; left:50%; display:none; position:absolute;">
<button>Way to go! Click here to change your mind.</button>
</div>
<div id="formbox<?= $row['Id'] ?>" style='position:absolute;'>
<form name='' id='form<?= $row['Id'] ?>' action='js/submit.php' method='post'>
<label>Keep:</label><input type='radio' name='dec[]' value='keep' <? if($row['Dec1']=='keep'){echo "checked='checked'";} ?> >
<label>Donate:</label><input type='radio' name='dec[]' value='donate' <? if($row['Dec1']=='donate'){echo "checked='checked'";} ?> >
<label>Sell:</label><input type='radio' name='dec[]' value='sell' <? if($row['Dec1']=='sell'){echo "checked='checked'";} ?> >
<label>Trash:</label><input type='radio' name='dec[]' value='trash' <? if($row['Dec1']=='trash'){echo "checked='checked'";} ?> >
<label>Give To:</label><input type='text' name='dec[]' size='15' <? if($row['Dec1']!='keep' && $row['Dec1']!='donate' && $row['Dec1']!='sell' && $row['Dec1']!='trash'){echo "value='".$row['Dec1']."'";} ?> >
<input type='hidden' name='id' value='<?= $row['Id'] ?>' />
<input type="submit" value="Submit">
</form>
</div>
</div>
</div>
</div>
<?
}