admin管理员组文章数量:1287579
am creating an application in laravel were one can select an option from a form select and he'll be redirected to another form based on the option selected.The options are from my database.
<script type="text/javascript">
function submitForm() {
var selectedOption = $('#service').val();
var url = "";
if(selectedOption == '{{ $val->id }} = 1') {
url = '{{ route('all.academics')}}';
} else if (selectedOption == '{{ $val->id }} = 2') {
url = '{{ route('all.it')}}';
} else (selectedOption == '{{ $val->id }} = 3') {
url = '{{ route('all.forex')}}';
}
$('#allServices').attr('action', url);
$('form#allServices').submit();
return true;
}
</script>
First Select Form, suppose redirect to the second form
<h3 class="card-title">PLACE AN ORDER</h3>
<p class="card-word">Select A Service Type Of Your Choice</p>
<form method="post" id="allServices" onsubmit="submitForm()">
@csrf
<div class="row">
<div class="col-lg-12">
<div class="mb-2">
<label class="form-label">Service Types</label>
<select class="form-control form-select mb-4" id="service" name="service">
<option>Select Service Type</option>
@foreach($services as $val)
<option value="{{ $val->id }}">{{ $val->service_categories }}</option>
@endforeach
</select>
</div>
</div>
</div>
<input class="btn waves-effect waves-light" type="submit" value="Order Now" style="background:teal; color: #fff;">
</form>
Second select form
<h3 class="card-title">PLACE AN ORDER</h3>
<p class="card-word">Select A Service Type Of Your Choice</p>
<form method="" action="" id="allServices">
@csrf
<div class="row">
<div class="col-lg-12">
<div class="mb-2">
<label class="form-label">Service Types</label>
<select class="form-control form-select mb-4" id="service" name="service">
<option>Select Service Type</option>
@foreach($academics as $aca)
<option value="{{ $aca->id }}">{{ $aca->academic_choice }}</option>
@endforeach
</div>
</div>
</div>
<input class="btn waves-effect waves-light" type="submit" value="Order Now" style="background:teal; color: #fff;">
</form>
本文标签:
版权声明:本文标题:Greetings guys, i'm trying to make a form select options that redirects base on select option to another form in laravel 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741256645a2366806.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论