-2

A1、A2、... のようにテーブルに挿入し、同じレコードが見つかったときにそれらを選択するかどうかを知りたいのですが、アンカータグが非表示になりますか?

                 for($i=0;$i<20;$i++)
                 {     
                ?>   
                        <input type="hidden"  name="ko[]" id="<?php echo $seatArr[$i];?>"/><a href="#" id="<?php echo $seatArr[$i];?>" onclick="myFunction(this)"><img src="images/<?php echo $seatArr[$i];?>.png" height="40" width="40" /></a>
                        </li>


            <?php } ?>
4

2 に答える 2

0

データベースから値を取得し、名前付きの配列に格納してい$seatArrて、同じ値に対して複数の非表示の入力フィールドを表示したくないと思います。

これを行うにはarray_unique()、php の関数を使用し、最初に一意の値を削除してから、コーディングを続けます。これにより、同じアドレスへのリンクが再度表示されるのを防ぐことができます。

$seatArr = array_unique($seatArr);

$count = count($seatArr)

for($i=0;$i<$count;$i++)
{  
?>   
<input type="hidden"  name="ko[]" id="<?php echo $seatArr[$i];?>"/>

<a href="#"
   id="<?php echo $seatArr[$i];?>"
   onclick="myFunction(this)">

<img src="images/<?php echo $seatArr[$i];?>.png" height="40" width="40" /></a>
</li>


<?php } ?>
于 2013-06-15T11:40:56.937 に答える
0

これを試して

$(document).ready(function(e) {
    $('a').each(function(index, element) {
        var this_a=$(this);
        if($(document).find('a[id="'+this_a.attr('id')+'"]').length>0)
        {
            $(document).find('a[id="'+this_a.attr('id')+'"]:gt(0)').remove();
        }
    });
}); 
于 2013-06-15T11:05:19.873 に答える