Greetings!
I don't know if it's possible or not, but I'd like to retrieve something from a selected option. If a question like this has already been asked, kindly redirect me to it. I'm still a beginner in Laravel so please have patience with me.
Anyways, here's my question:
I have this part of my element to keep the dept_code of the selected item.
<option data-code="{{ $dept->dept_code }}">{{ $dept->dept_name }}</option>
Now i want to get the value of data-code in the element. I'm only able to retrieve the value of $dept->dept_name by using this Input::all() but that's not what I want.
Can anyone help me with this? If I need to provide more info, please tell me. Thanks!
IIRC data-* attributes are used mainly for CSS and Javascript. You'll want to use the value
attribute
<option value="{{ $dept->dept_code }}">{{ $dept->dept_name }}</option>
gizzmo said:
IIRC data-* attributes are used mainly for CSS and Javascript. You'll want to use the
value
attribute
<option value="{{ $dept->dept_code }}">{{ $dept->dept_name }}</option>
thanks gizzmo, how do we retrieve it then? I think Input::all() will not do the trick.
\Input:all();
Will give you all fields, so you would need to do something like
$input = \Input::all();
$var = $input['select'];
This assumes your select is named "select":
<select name="select">
,,,,
You might want to also look at "request" in the docs as well: http://laravel.com/docs/5.1/requests#retrieving-input
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community