I need to create the dependent drop down list for same colum

i need ur help..i am creating a web application about books entry using yii. in a form i need to dropdown a isbn number from one table that should retrieve the relavive book title which is in the same row in another text field or dropdown box….i hope u understand my prob please give suggestion.here is my …

via HTML Language Development » Search Results » ajax:

I need to create the dependent drop down list for same colum

i need ur help..i am creating a web application about books entry using yii. in a form i need to dropdown a isbn number from one table that should retrieve the relavive book title which is in the same row in another text field or dropdown box….i hope u understand my prob please give suggestion.here is my coding for html view page

labelEx($model,’isbn_no’); ?>
dropDownList($model,’isbn_no’,CHtml::listData(Books::model()->findAll(array(‘order’=> ‘isbn_no ASC’)), ‘isbn_no’, ‘isbn_no’),array(‘empty’=>’Select’),array(
‘ajax’ => array(
‘type’ => ‘POST’,
‘url’ => CController::createUrl(‘Processcontroller/Book’),
‘update’ => “#book_title”
)));?>
error($model,’isbn_no’); ?>
labelEx($model,’book_title’); ?>
dropDownList($model,’book_title’,”,array(),array(‘empty’=>’select’));

error($model,’book_title’); ?>

my controller named ProcessController.php
public function actionBook()

//please enter current controller name because yii send multi dim array
$data=Books::model()->findAll(‘book_id=:book_id’,
array(‘:book_id’=> $_POST[‘current-Controller’][‘book_id’]));

$data=CHtml::listData($data,’isbn_no’,’book_title’);
foreach($data as $value=>$name)

echo CHtml::tag(‘option’,
array(‘value’=>$value),CHtml::encode($name),true);

}…. my table will be like below named Books book_id(PK) | isbn_no | book_title |
……………………………………….

The only problem I can see in your code is that
IN YOUR CONTROLLER
$data=Books::model()->findAll(‘book_id=:book_id’,
array(‘:book_id’=> $_POST[‘current-Controller’][‘book_id’]));while you should compare isbn_no as you are sending isbn_no from the form to controller…
$data=Books::model()->findAll(‘isbn_no=:isbn_no’,
array(‘:isbn_no’=> $_POST[‘current-Controller’][‘isbn_no’]));If some other error is showing then please mention..as the code seems alright…and you have not mentioned what is the error..

For more info: I need to create the dependent drop down list for same colum

HTML Language Development » Search Results » ajax

I need to create the dependent drop down list for same colum

Share this post:

Related Posts

Leave a Comment