0

I'm new to yii framework. I have created a simple dropdownlist.

echo $form->dropDownList($model, 'max_cost', array('2'=>'Yes', '0'=>'No'), 
                                  array(
                                          'empty'=>'Choose one', 
                                          'onchange'=>'alert(item.value);',
                                          )
                                  );  

Now when I select Yes, the alert box will display Yes and when i select no the alert box will display no. Suppose I want to display 2 when I select yes and 0 when I select no . What should I do for this? item.value displays the RHS I want to display LHS

1
  • I tried alert(value), is it the right way to do it Commented Nov 16, 2013 at 10:37

1 Answer 1

1

log the "item" and you will know what are exactly parameters bound to items, then you can alert it or whatever you need:

'onchange'=>'console.log(item);', // here you can see what's inside item
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.