Change input, based on select:option

Posted 4 months ago by splendidkeen

I have a Verification.php Model, with a verification_table:id, name, city, country

I want to put the select option below, before a signup form. After the user selected a verification, we need to parse the values of $verification into the signup form.

<select> 
        <option value="0">Select your information</option>
                @foreach(App\Models\Verification::all() as $verification)
                    <option value="{{$verification->id}}">{{$verification->city}}</option> 
                @endforeach 
</select> 

How can one build a bridge from the select option to the form input?

@if(select != 0)

put $verification->city into the input #ver-city

@else

let user type its information

@endif 

Signup:

<form>
<div>
<input type="text" name="city" value="{{ Request::old('city') ?: ''}}" id="ver-city" placeholder="{{__('auth.partner-fn-placeholder')}}">
              

@if ($errors->has('city'))
<span>{{ $errors->first('city') }}</span>
@endif
</div>
</form>

The process should help pre-validate upcoming users. Any ideas how to provide the bridge?

Kindest Regards

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.