Support the ongoing development of Laravel.io →
Input Session Forms
Last updated 1 year ago.
0

I think u will need javascript to add the value to the select box. Do u use a js library like jQuery? U need to add the value to the select box with javascript after the user has created a new customer, or u can load the whole list again from database and put this list in the select box.

Last updated 1 year ago.
0

Thanks for the reply. I use jQuery for the modal box and several other things.

What I need is a method of retrieving the ID of the created customer and then pass that ID into the value of the select box.

Guess you can break it down to:

a) How do I retrieve the ID of the created customer? b) How do I pass that value into the select box?

Last updated 1 year ago.
0

superstoffer said:

Thanks for the reply. I use jQuery for the modal box and several other things.

What I need is a method of retrieving the ID of the created customer and then pass that ID into the value of the select box.

Guess you can break it down to:

a) How do I retrieve the ID of the created customer? b) How do I pass that value into the select box?

Since you're using jQuery, why not just have laravel return the newly created user in the reponse, like:


#lets imagine this is a resource controller
public function store(){
     ...
     $user->save();
     return Response::json($user, 200);
}

Then, get that data from your ajax success method, and then do an $('.dropDown').append('NEW USER OPTION TAG');

EDIT:

In jquery, you should use:


$.post(urlToSaveNewUser, data,  function(response){
     /* response will contain you new user data */
    console.log(response); 
}, 'json');

Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

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

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.