doueta6642
2011-08-31 04:39
采纳率: 0%
浏览 31
已采纳

CakePHP问题:如何从radiobutton获得价值以及如何调用动作?

<div id="rightsidesix" >

    <?php echo '<div class="class_color_title" ><b>'."Polls".'</b></div>'; ?>

    <?php

        echo '<div id="id_color_polls" >';

            echo '<p><b>Which linux distribution do you like most ?</b></p>'.'<br/>';

            $options=array('F'=>'Fedora','U'=>'Ubuntu','D'=>'Debian','O'=>'openSuse','M'=>'Mandriva','T'=>'Other');

            $attributes=array('legend'=>false);

            echo $this->Form->radio('distributions',$options,$attributes);

            echo $this->Form->button('Check',array('id'=>'id_btnpolls'));

        echo '</div>';

        echo '<br/>';

    ?>

</div>      

Should i add these form input/radio buttons in a form ?

After clicking the button it will call jQuery function.

$("#id_btnpolls").click(function(){



    var valCheckedRadio = $('input[name=data[distributions]]:checked').val()

    alert(valCheckedRadio);



    $.ajax({

        type: "POST",

        url: "<?php Router::url(array('controller'=>'posts','action'=>'polls')); ?>,",

        data: "valCheckedRadio="+valCheckedRadio,

        success: function(prm){

            //alert(prm);

            $("#id_color_polls").html(prm);

        }

    });
})

Is this correct way to call an action of a controller ?

        url: "<?php Router::url(array('controller'=>'posts','action'=>'polls')); ?>,",
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

相关推荐 更多相似问题