Advertisement
Guest User

Untitled

a guest
Jul 30th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. <?php
  2. //First drop-down
  3. echo $form->field($model, 'client')->dropDownList($Client,
  4. ['prompt'=>'-Select Client-',
  5. 'onchange'=>'
  6. $.post
  7. (
  8. "'.urldecode(
  9. Yii::$app->urlManager->createUrl
  10. ('leads/lists&id=')).'"+$(this).val(), function( data )
  11. {
  12. $( "select#staff_id" ).html( data );
  13. });
  14. ']); ?>
  15.  
  16. // depend dropdown
  17. <?php echo $form->field($model, 'staff')
  18. ->dropDownList
  19. (
  20. ['prompt'=>'-Choose a Sub Category-'],
  21. ['id'=>'staff_id','value'=>$Staff]
  22. );
  23. ?>
  24.  
  25. public function actionLists($id)
  26. {
  27. $sql = "select * from staff where client='$id' ";
  28. //exit;
  29. $models = Staff::findBySql($sql)->asArray()->all();
  30. //echo "<pre>";print_r($model);exit;
  31.  
  32. if(sizeof($models) >0){
  33. echo "<option>-Choose a Sub Category-</option>";
  34. foreach($models as $model){
  35. echo "<option value='".$model['id']."'>".$model['fname']."</option>";
  36. }
  37. }
  38. else{
  39. echo "<option>-Choose a Sub Category-</option><option></option>";
  40. }
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement