剑圣 2015-07-08 15:45:20 3448次浏览 0条回复 0 0 0

我尝试着仿照百度知道写一个系统,想请教大家一个问题: “采纳”这一功能,多选一,如果楼主采纳了某一用户的回帖,其它用户留言下面的“采纳答案”这一按钮消失。 这个功能用yii该怎么实现? 或者说 这个功能用jquery该怎么实现?

<?php
Yii::app()->clientScript->registerCoreScript('jquery');
//Yii::app()->clientScript->registerCoreScript('jquery.ui');
?>
<script type="text/javascript">
$(document).ready(function(){
  $("#hide").click(function(){
  $("#edui").toggle();
  });
});
</script>
<div>
    <table border="1">
        <tbody>
            <?php foreach($infos as $v)
            {
                $v->browse++;
                echo "<table>
                      <tr>
                      <td>$v->title</td>
                      </tr>
                      <tr>
                      <td><a>$v->netname</a>|分类:$v->typename|浏览$v->browse
                          次</td>
                      <td align='right' width=120>$v->addtime</td>
                      </tr>";
                if(!empty($v->filename))
                {
                    $picture = "uploads/$v->filename";
                    echo "<tr><td><img src=$picture></td></tr>";
                }
                echo "<tr><td colspan=2>$v->content</td></tr></table>";
            }
            ?>
        </tbody>
    </table>
</div>
<br>
        <?php foreach($reply as $_v)
        {
            echo "<div><table>";
            if($_v->topindex == 1)
            {
                echo '<tr><td>提问者采纳</td></tr>';
            }
            echo "<tr><td>$_v->netname</td><td align='right' width=120>$_v->addtime</td></tr>
                <tr><td colspan=2>$_v->content</td></tr>";
                if(!empty($_v->title))
                {
                    $path = "uploads/$_v->title";
                    echo "<tr><td><img src=$path></td></tr>";
                }
                if(($_v->user_id == Yii::app()->user->id) && $_v->topindex == 0)
                {
                    ?>
                    <tr>
                        <td><a href='#'>修改回答</a></td>
                        <td>
                            <a href="./index.php?r=question/del&id=<?php echo $v->id;?>&rid=<?php echo $_v->id;?>" onclick="return confirm('确定要删除吗?')" >
                                删除回答
                            </a>
                        </td>
                    </tr>
                    <?php
                }
                if(($v->user_id == Yii::app()->user->id) && $_v->topindex == 0)
                {
                    ?>
                    <tr>
                        <td></td>
                        <td>
                            <a href="./index.php?r=question/update&id=<?php echo $v->id;?>&rid=<?php echo $_v->id;?>" onclick="return confirm('确定要采纳吗?')">
                                采纳回答
                            </a>
                        </td>
                    </tr>
                    <?php
                }
                echo "</table></div>";
        }
        ?>
<br>
<?php 
if(Yii::app()->user->id != $v->user_id)
{
?>
<div>
    <input id="hide" type="button" value="我来回答" />
</div>
<div id="edui" style="display: none">
    <?php $form = $this->beginWidget('CActiveForm',array(
        'enableAjaxValidation'=>false,
        'htmlOptions'=>array('enctype'=>'multipart/form-data'),
    ));
    ?>
    <table border="1">
        <tr>
            <td><?php echo $form->labelEx($model,'content');?></td>
            <td><?php echo $form->textArea($model,'content',array('cols'=>30,'rows'=>5));?></td>
            <td><?php echo $form->error($model,'content');?></td>
        </tr>
        <tr>
            <td><?php echo $form->label($model,'title');?></td>
            <td><?php echo $form->fileField($model,'title');?></td>
            <td><?php echo $form->error($model,'title');?></td>
        </tr>
        <tr>
            <td colspan="2" align="center">
                <input type="submit" value="提交" onclick="jh()"/>
            </td>
        </tr>
    </table>
    <?php $this->endWidget();?>
</div>
<?php
}
    没有找到数据。
您需要登录后才可以回复。登录 | 立即注册