0
この投稿に割り当てられたラジオボタンが選択されているときに、投稿の下部に表示する必要があるDIV #Message_PHPVARABLEがあります。ただし、Post_1ではうまくいきますが、Post_2のオプションを選択するとPost_1のオプションが変更され、Message_1にPost_2の選択肢が表示される代わりにMessage_1に新しい選択肢が表示されます。ラジオボタンのオプションは「好き嫌い」です。ラジオボタンのjQuery変数でメッセージを表示できません
$data = mysql_query("SELECT * FROM Test");
$counter = 1;
while($row = mysql_fetch_array($data)){
?>
<script type="text/javascript">
$(document).ready(function() {
$("input[name*='like_<?php $counter; ?>']").click(function() {
var defaultValue = $("label[for*='" + this.id + "']").html();
var defaultm = "You have chosen : ";
$('#Message_<?php $counter; ?>').html('').html(defaultm + defaultValue + ' | Value is : ' + $(this).val());
});
});
</script>
<div id="post_<?php $counter; ?>" class="post">
<b><?php echo $row['Title']; ?></b><br>
Expires: <?php echo $row['Exp']; ?><br>
<ul id="listM"></ul>
<div class="left"><p><input id="like_<?php $counter; ?>" type="radio" name="like_<?php $counter; ?>" value="1" />
<label for="like_<?php $counter; ?>">Like</label></p></div>
<div class="right"><p><input id="dislike_<?php $counter; ?>" type="radio" name="like_<?php $counter; ?>" value="0" />
<label for="dislike_<?php $counter; ?>">Dislike</label></p></div>
<hr />
</div>
<div id="Message_<?php $counter; ?>"></div>
<?php
$counter += 1;
}
?>
私はハードコードのすべて($カウンタを削除する)、それが表示されるMySQLでの潜在的な行の数が無限で、正常に動作しますが、明らかに、私は、変数を使用する必要がある場合は...
WOW、なんと素人ミス! – Sweepster