YiiBooster
YiiBooster copied to clipboard
how to get value of TbSelect2 with Javascript?
// ``` $this->widget( 'bootstrap.widgets.TbSelect2', array( 'htmlOptions'=>array('id'=>'Gandu'), // 'initSelection'=> array("USD"=>"US Dollars"), 'name'=>'Gandu', 'model'=>$model, // 'val' => array("USD"=>"US Dollars"), 'attribute' => 'Currency', 'data' => TbHtml::listData(TblCurrency::model()->findAll(),'currency_code','currency'), 'options' => array( 'placeholder' => 'Click to Select a Currency Type', 'width' => '30%', ) ) ); ?>
<p>Click the button to display an alert box:</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
var x=document.getElementById("#Gandu");
alert(x.innerHTML);
// alert("I am an alert box!");
}
</script>