Reputation: 35
I am using a select control in my view , and I use the id
to save it in a table, but i need too id
name
, to confirm this id
and name
. that in fact is a table (services)
I have used this two way of code that makes the same ... but I need get the id
e name
in diferent variables.
<select ="serv" name="serv">
@foreach($serv as $id=>$name)
<option value="{{$id}}">{{$name}}</option>
@endforeach
{!! Form::select('serv',$serv,null,['id'=>'serv'])
Upvotes: 0
Views: 105
Reputation: 35
Thanks! finally i used a script at onchange event , where i get the value and text of the select and then send this text to a hidden control.
<script type="text/javascript">
function ShowSelected()
{
var cod = document.getElementById("serv").value;
var combo = document.getElementById("serv");
var selected = combo.options[combo.selectedIndex].text;
document.getElementById("serv2").value=selected;
}
</script>
Upvotes: 0
Reputation: 581
Do like this
{{ Form::select('serv',$serv->id,null,['id'=>'serv']) }}
Upvotes: 1