user1012181
user1012181

Reputation: 8726

How to get the select option value in Laravel

I have a select option just like below.

<select name = "type">
 <option value="">Select one</option>
 <option value="1">Abc</option>
 <option value="2">Xyz</option>
</select>

I tried to get the value using Input::get('type')But getting the labels Abc. I need to get the value as 1 or 2 or 3 depending on the one that I'm selecting. I even tried this

<select name = "type" onchange="document.getElementById('typeId').value=this.options[this.selectedIndex].value;">

But same thing happened. How can I do this?

Upvotes: 0

Views: 1852

Answers (1)

Federkun
Federkun

Reputation: 36934

Just

document.getElementById('typeId').value=this.value;

Upvotes: 1

Related Questions