How to display data in table row from drop down list


Emorej posted 1 week ago

Hello everyone... I'm new in Laravel.. Problem: How to display data in table row from drop down list (as my input search).. Scenario: I would like to use my four drop down list as a trigger for my search... then i would like to make a function button as trigger to display data in my table row... hope anyone will help me.

this is my model.(where i query the search)

public function scopeGetSL($query, $SLE_TypeCode,$COAID,$parent_baltype,$parent_loanpayrep,$SLE_TypeDesc,$COADesc,$BalTypeDesc,$LoanPayRepClassDesc) { return $query->where('SLE_TypeCode','like','%' .$SLE_TypeCode. '%') ->orWhere('SLE_TypeDesc','like','%' .$SLE_TypeDesc. '%') ->orWhere('COAID','like','%' .$COAID. '%') ->orWhere('COADesc','like','%' .$COADesc. '%') ->orWhere('BalTypeID','like','%' .$BalTypeID. '%') ->orWhere('BalTypeDesc','like','%' .$BalTypeDesc. '%') ->orWhere('LoanPayRepClassID','like','%' .$LoanPayRepClassID. '%') ->orWhere('LoanPayRepClassDesc','like','%' .$LoanPayRepClassDesc. '%');

}

this is my cotnroller (and i'm not sure to it.. it was already destroyed) ** $glcontrol = Glcontrol::getSL($request->sle_type,$request->coaid,$request->bal_type,$request->rep_class); ** this is my AJAX/Jquery (not complete because i don't know how to code AJAX )

<script> function getRecords(event){ event.preventDefault(); sle_type = $("#sle_type").val(); coaid = $("#coaid").val(); bal_type = $("#bal_type").val(); rep_class = $("#gl_control").val(); axios.get('http://localhost:8000/sl?sle_type=' + sle_type + '&coaid=' + coaid + '&bal_type=' + bal_type + '&rep_class=' + rep_class ) .then(response => { console.log(response.data) }) .catch(error =>{ console.log(error.response) }); }; </script>

and this are the select and button..

<form> <span> <select class="form-control" id="sle_type" data-parsley-required="true" name="sle_type" style="width: 200px;"> <option>N/A</option> @foreach($sle_type as $key => $val) { <option value="{{ $val->SLE_TypeCode }}"> {{$val->SLE_TypeCode}}=>{{ $val->SLE_TypeDesc }} </option> } @endforeach </select> </span>
				<span>
					<select class="form-control"  id="coaid" data-parsley-required="true" name="coaid" style="width: 200px;">
						<option>N/A</option>
						@foreach($coa as $key => $val)
						{
							<option value="{{ $val->COAID }}">{{ $val->COAID }}=>{{ $val->COADesc }}</option>
						}
						@endforeach
					</select>
				</span>

				<span>
					<button type="submit" class="btn btn-primary">Find</button>
				</span>

				<span>
					<select class="form-control"  id="bal_type" data-parsley-required="true" name="bal_type" style="width: 200px;">
						<option> N/A </option>
						@foreach($baltype as $key => $val)
						{
							<option value="{{ $val->BalTypeID }}">{{ $val->BalTypeID }}=>{{ $val->BalTypeDesc }}</option>
						}
						@endforeach
					</select>
				</span>

				<span>
					<select class="form-control"  id="rep_class" data-parsley-required="true" name="rep_class" style="width: 200px;">
						<option>N/A</option>
						@foreach($coa as $key => $val)
						{
							<option value="{{ $val->LoanPayRepClassID }}">{{ $val->LoanPayRepClassID }}=>{{ $val->LoanPayRepClassDesc }}</option>
						}
						@endforeach
					</select>
				</span>

				<span>
					<button class="btn btn-primary" onclick="getRecords()">Insert</button>
					<!-- <input type="button" class="btn btn-primary" name="insert" value="Insert" id="add-row"> -->
				</span>

				<br><br>

				</form>

Hope you will me understand it.. Thanks.


Sign in to participate in this thread!


We'd like to thank these amazing companies for supporting us