dimanche 9 septembre 2018

selectbox combined value in laravel view page

I have a selectbox which has two field combined value as single option eg :name1(name1_code),name2(name2_code) and populated this value from ajax call response. I have single form for submit form and edit page.If I have a $id I want to populate the value in select box.I have tried as

js code
$.each(data, function(key, value) {     //populate value 
   $('#project_name').append($("<option></option>")
   .text(value).attr("value",key)); 
});

Php

if(isset($id))          
{
 $types=DB::table('sow_mapping as m')->leftJoin('sow as s','m.sow_id','=','s.id')->leftJoin('project as p','p.id','=','m.project_id')->where('p.code','=',$asset_request->project_code)->pluck('s.number','s.code')->all();
 $sow_code=db::table('sow')->where('code',$asset_request->sow)->value('number');
 echo Form::select('sow_name',
    [''=>'Select']+$types,$asset_request->sow.'('.$sow_code.')',['class'=>'selectpicker default','id'=>'sow_name']);
 }



print_r($types) output as 
   Array ( [SOW_1395] => WJT - SOW 07 ) 

 I want to print as  `SOW_1395(WJT - SOW 07)`

Is it possible to print as SOW_1395(WJT - SOW 07)



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2Nuwkfj
via IFTTT

Aucun commentaire:

Enregistrer un commentaire