YiiBooster icon indicating copy to clipboard operation
YiiBooster copied to clipboard

how to get value of TbSelect2 with Javascript?

Open sachy123 opened this issue 11 years ago • 0 comments

// ``` $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>

sachy123 avatar Oct 22 '14 10:10 sachy123