Change A Hidden Field And Submit Form

hi:

I am a PHP programmer, but new to YII programming. I am quite used to:

1.using a frontend button onclick event, when triggered:

2.change a hidden value

3.do form submit

to let the page do different behavior than the default one

How can I do that by YII?

It’s quite similar to the normal html and Javascript.

First declare a button and input hidden field.




<?php echo CHtml::hiddenField('name' , 'value1', array('id' => 'hiddenInput')); ?>

<?php echo CHtml::button("Edit",array('title'=>"Edit",'id'=>'myButton')); ?>



Then the Javascript.




window.onload = function() {

    document.getElementById("myButton").onclick = function() {

        //alert("test");

        document.getElementById("hiddenInput").value = "value2";

        return false;

    }

}



Now the hidden value changes from ‘value1’ to ‘value2’.

OK, I got it (I guess). Therefore, YII seems to use jQuery more convenient than pure JavaScript, because the default element use class more than id or name.