I have a dropdown. I want to show the loop input files from the database by selecting the dropdown.
Detail of the case: if I choose one dropdown, it will show input_file derived from table loop_atachment (doctype column) based on groupid selected.
This is my code.
Dropdown in blade :
<select id="groupid" name="groupid" class="form-control">
<option value="">Choose</option>
<option value="1">General</option>
<option value="2">Golf Club</option>
</select>
Input file should be display here when select dropdown:
<div class="form-group">
<label class="control-label">loop attachment</label>
</div>
Javascript/ajax :
$('#groupid').on('change', function(){
$.post('', {type: 'loop_attachment', id: $('#groupid').val()}, function(e){
$('#image').html('');
$('#image').html(e);
});
});
Controller :
public function postDynamic(Request $request)
{
switch(Input::get('type')):
case 'loop_attachment':
$return = '<input type="file" id="">';
foreach(Loop_attachment::where('groupid', Input::get('id'))->get() as $row)
$return .= "<input type='file' id='$row->id'>$row->doctype";
return $return;
break;
endswitch;
}
Currently, does not display any file input when selecting the dropdown, I hope anyone can help me here. Thanks in advance
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire