Make the tags and select list active without using Form Builder in laravel? - forms

I am unable to make a dropdown select list using the below code to generate a location select dropdown where database table =>location and column=>name
<select name="location">
#foreach ($locations as $loaction)
<option value="{{ $loaction->name }}">{{ $loaction->name }}</option>
#endforeach
</select>

Related

Dropdown automate in VBA

I need some help: I want to select value from cell d2 on website but unfortunately there are two dropdown menus on the same web page and same value this is my code
If ThisWorkbook.Sheets("sheet1").Range("d2").Value = "ÇáËÇäí" Then
obj.FindElementById("ddlTerm").FindElementByXPath("//*[#value='2']").Click
but if I select finfbyid in dropdown menu in need to specify which option I need so my option has the value of 2 but there another dropdown list has same value
Here is the list that I need
<select name="ddlTerm" id="ddlTerm" style="width: 160px;" onclientchange="EnableDisableShowButton();">
<option title="الفصل الاول" value="1">الفصل الاول</option>
<option value="2">الفصل الثانى</option><option value="4">الدور الثانى</option>
</select>
but this list has same option value
<select name="SchoolFilterCtrl1$ddlEducationSystems" id="SchoolFilterCtrl1_ddlEducationSystems" style="width: 160px;">
<option selected="selected" value="2">أساسي</option>
</select>

insert data if not exist in the column using Laravel elequant

I'm developing a doctor's appointment laravel project. the condition is if a user fixes an appointment they can't able to fix the appointment for the same doctor at the same date and time. I tried with firstOrCreate method but doesn't match my condition. here are my conditions
1.if doctors_id AND date AND time already exist then shouldn't insert the data
2.if doctors_id OR date OR time, any three of this already exist then can insert the data
3.if all fields already not exist then insert data
here are the code snippets
In view
<div class="card-body">
<form action="appointment" method="post">
{{ #csrf_field() }}
<select name="doctors" id="" class="form-control">
#foreach ($docList as $item)
<option value="{{$item->id}}">{{$item->name}}</option>
#endforeach
</select><br><br>
<input type="date" name="date" id="" class="form-control">
<br><br>
<select name="time" class="form-control">
<option value="9-10AM">9-10AM</option>
<option value="10-11AM">10-11AM</option>
<option value="1-2PM">1-2PM</option>
<option value="2-3PM">2-3PM</option>
<option value="3-4PM">3-4PM</option>
</select>
<button type="submit" class="btn btn-primary">Fix Appointment</button>
</form>
</div>
In controller
public function store(Request $request)
{
$uId = Auth::id();
$fixAppointment = Appointment::firstOrNew(['doctors_id'=>$request->doctors,'date'=>request('date')],['time'=>request('time')]);
$fixAppointment->users_id = $uId;
$fixAppointment->save();
}
Here I sorted out the issue by using where condition
In controller
$appointment = Appointment::where('date', '=', request('date'))->where('time','=',request('time'))->where('doctors_id','=',request('doctors'))->first();
if ($appointment === null)
{
$fixAppointment = New Appointment;
$fixAppointment->doctors_id = $request->doctors;
$fixAppointment->users_id = $uId;
$fixAppointment->date = $request->date;
$fixAppointment->time=$request->time;
$fixAppointment->save();
}
here is the link which I referred to find this solution.

Vue multiple select

I would like to have multiple selections without multiple.vue librabry. I want to write it by my own. I have data like this in js:
data:
roles : [here data]
form.roles: []
And my html with Vue:
<select class="form-control required-select2" v-model="form.roles" id="roles" required>
<option v-for="role in roles" v-bind:value="role.id" v-bind:selected="form.roles.indexOf(role.id) > -1">
{{ role.display_name }}
</option>
</select>
How can I have in form.roles more than one role.id? I have to write maybe a method for this?
Do you want to do something like https://codepen.io/ittus/pen/vjdLvb
You need to add multiselect options to your select
<template>
<select class="form-control required-select2" v-model="form.roles" id="roles" multiple required>
<option v-for="role in roles" v-bind:value="role.id" v-bind:selected="form.roles.indexOf(role.id) > -1">
{{ role.display_name }}
</option>
</select>
<div>Selected: {{ form.roles }}</div>

Angular2 reactive forms select how to set invalid?

I use reactive forms within my app. In a certain form I want to display a required (Validators.required) select like this:
<select class="form-control"
[id]="dformControl.key"
[formControlName]="dformControl.key"
[multiple]="dformControl.multiple">
<option *ngIf="!dformControl.value"
value="undefined">
Choose ...
</option>
<option *ngFor="let opt of dformControl.options"
[value]="opt.value"
[selected]="dformControl.value == opt.value">
{{opt.label}}
</option>
</select>
The problem is whether I use value="undefined" or value="" the form control still is set to valid because it got a value. Do not present the value attribute results in value="Choose ...".
Am I using select with reactive forms in a false way or how would I be able to make the option "Choose ..." being not valid??
Assigning initial value of select control to null will do the trick. Try below,
model_property = null
....
this.fb.group({
....
'control_key' : [this.model_property, Validators.required]
...
})
Check this Plunker!!, Look into app/reactive/hero-form-reactive.component.ts file.
I updated the Plunker to include below and it seems to be working,
<select id="power" class="form-control"
formControlName="power" required >
// see the value is set to empty,
<option value="">Choose...</option>
<option *ngFor="let p of powers" [value]="p">{{p}}</option>
</select>
Hope this helps!!
What I do is add a blank option and when that is selected since there is no value it is not valid.
<select class="form-control"
[id]="dformControl.key"
[formControlName]="dformControl.key"
[multiple]="dformControl.multiple">
<option></option>
<option *ngFor="let opt of dformControl.options"
[value]="opt.value"
[selected]="dformControl.value == opt.value">
{{opt.label}}
</option>
</select>

Default value on form select (with foreach loop)

So, I want to achieve a <select> like solution where a default value is equal to the value that is currently in the database, so the 'old value'.
1
I have this, where I loop a foreach to fill <option>.:
<select id="size" name="size" class="form-control">
#foreach ($sizes as $s)
<option value="{{ $s->value }}">{{ $s->name }}</option>
#endforeach
</select>
Now where I want to use this is an edit-form in laravel 5.2 where it fills in this form with the current values from the database for the selected user. My input fields with text fill in correctly but this select doesn't.
2
Working with Laravel forms I know this is possible to set the default value to S. But I don't know how to loop this is foreach...:
{{ Form::select('size', array('L' => 'Large', 'S' => 'Small'), 'S') }}
So I need to find a way to set default value with HTML-select tags while in a loop with values from my controller or find a way to loop in Laravel Forms.. Either is good, as long as it works
Don't know if this is what You are asking, but if You know current value, You can check it with if statement:
<select id="size" name="size" class="form-control">
#foreach ($sizes as $s)
#if ($s->value == $currentSize)
<option selected value="{{ $s->value }}">{{ $s->name }}</option>
#else
<option value="{{ $s->value }}">{{ $s->name }}</option>
#endif
#endforeach
</select>