Hi,
i have a DropDownList in my Form.
Onchange the DDL i want to open a new Browserwindow with a dynamic URL.
My Code in the Form is this:
<div class="row">
<?php echo $form->labelEx($model,Yii::t('Device','productID')); ?>
<?php echo CHtml::DropDownList($model,'productID', $model->getProducts(),array('prompt' => Yii::t('Device','(Select Product)'), 'onChange'=>'window.open("index.php?r=product/view&id=1", "popup", "width=1024, height=768");')); ?>
<?php echo $form->error($model,'productID'); ?>
</div>
My Problem is that the ID in the URL must be the Value of the DDL but i have no idea how i can make this.
Thanks for your help.
Carsten
Use this.value property to get selected value, see below code
Thank you for your help, but with this code i get an error
Object of class Device could not be converted to string
Try this Carsten
<?php echo CHtml::DropDownList($model,'productID', $model->getProducts(),array('prompt' => Yii::t('Device','(Select Product)'), 'onChange'=>'window.open("index.php?r=product/view&id="'.this.value, '"popup", "width=1024, height=768");')); ?>
use +this.value at end of url like
echo $form->dropDownList($model, 'setDefinitionID', CHtml::listData(SetDefinition::model()->findAll(), 'id', 'setName'), array('prompt' => 'Select','id'=>'dd','onChange'=>'window.open("index.php?r=product/view&id="+this.value, "popup", "width=1024, height=768");'));
It works, thanks for your help.