Yii Framework Forum: Yii - How To Get Option Value Different In Ext.combobox.ejuicombobox From The Name Displayed - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Yii - How To Get Option Value Different In Ext.combobox.ejuicombobox From The Name Displayed Rate Topic: -----

#1 User is offline   Rudra 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 118
  • Joined: 12-July 13

Posted 14 November 2013 - 02:30 AM

I'm using `ext.combobox.EJuiComboBox` to create a dropdownlist. When I use this I get the HTML as below :
    <select id="SearchForm_max_cost_select" style="display: none;">
    <option value="0"></option>
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
    <option value="5">5</option>
    <option value="6">6</option>
    </select>  

but I want it like this :
    <select id="SearchForm_max_cost_select" style="display: none;">
    <option value="0"></option>
    <option value="1">one</option>
    <option value="2">two</option>
    <option value="3">three</option>
    <option value="4">four</option>
    <option value="5">five</option>
    <option value="6">six</option>
    </select>  

I'm using the below code,
    <?php
      $this->widget('ext.combobox.EJuiComboBox', array(
                        'model' => $model,
                        'attribute' => 'min_cost',                                   
                         'data' => array('1','2','3','4','5','6'),                                            
                    
                        'options' => array(
              'onSelect' => 'cost_change(item.value);',
                            'allowText' => false,
                        ),
                    
                        'htmlOptions' => array('placeholder' => 'Min Cost', 'style'=>'width:70px'),
                    ));
                   
    
                    ?>

How can I do this?
0

#2 User is online   chandran 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 488
  • Joined: 08-October 12
  • Location:Austria

Posted 14 November 2013 - 03:23 AM

Hi

Here is a example

<select id="myselect">
    <option value="1">Mr</option>
    <option value="2">Mrs</option>
    <option value="3">Ms</option>
    <option value="4">Dr</option>
    <option value="5">Prof</option>
</select>


the value to be sent to the server

$( "#myselect" ).val();    // => 1


If you wanted to get the string "Mr" if the first option was selected

$( "#myselect option:selected" ).text();  // => "Mr"



<?php
$this->widget('ext.combobox.EJuiComboBox', array(
    'model' => $model,
    'attribute' => 'password',
    // data to populate the select. Must be an array.
    //'data' => $model->getAllModels(),
    'data' => array('yii','is','fun','!'),
    // options passed to plugin
    // Options passed to the text input
    'options' => array(
        // JS code to execute on 'select' event, the selected item is
        // available through the 'item' variable.
        'onSelect' => 'alert("selected value : " + item.value);',
        // JS code to be executed on 'change' event, the input is available
        // through the '$(this)' variable.
        'onChange' => 'alert("changed value : " + $(this).val());',
        // If false, field value must be present in the select.
        // Defaults to true.
        'allowText' => false,
    ),
    // Options passed to the text input
    'htmlOptions' => array('size' => 10),
)); ?>



Thanks
chandran nepolean

My own extension:
http://www.yiiframew...sion/ejqueryte/

My wiki
http://www.yiiframew...checkboxcolumn/

If it work dont hesitate to click +1 button
0

#3 User is offline   Rudra 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 118
  • Joined: 12-July 13

Posted 14 November 2013 - 03:34 AM

Hello Chandran,
I want the HTML to be generated like :
<select id="SearchForm_max_cost_select" style="display: none;">
    <option value="0"></option>
    <option value="1">one</option>
    <option value="2">two</option>
    <option value="3">three</option>
    <option value="4">four</option>
    <option value="5">five</option>
    <option value="6">six</option>
    </select>  

But, it is generated as below,
<select id="SearchForm_max_cost_select" style="display: none;">
    <option value="0"></option>
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
    <option value="5">5</option>
    <option value="6">6</option>
    </select>  

Now, for the dropdownlist, I'm passing
'onSelect'= 'cost_change(item.value)';
.
0

#4 User is online   chandran 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 488
  • Joined: 08-October 12
  • Location:Austria

Posted 14 November 2013 - 03:48 AM

Hi,

There is a small misunderstood. You can achieve this by below code

// data to populate the select. Must be an array.
    'data' => array('1'=>'one','2'=>'Two') // ..and continues
    'assoc'=>true,

Thanks
chandran nepolean

My own extension:
http://www.yiiframew...sion/ejqueryte/

My wiki
http://www.yiiframew...checkboxcolumn/

If it work dont hesitate to click +1 button
0

#5 User is offline   Rudra 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 118
  • Joined: 12-July 13

Posted 14 November 2013 - 04:15 AM

Still no change. Same is the HTML generated
<select id="SearchForm_min_cost_select" style="display: none;">
<option value="0"></option>
<option value="one">one</option>
<option value="Two">Two</option>
</select>

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users