mercredi 5 août 2015

Autocomplete multiple fields based on one field (jQuery Autocomplete)


My JSON information:

{
"RES_ID":"2622959",
"PROP_ID":"76055",
"RES_CHECK_IN":"2015-04-21",
"RES_CHECK_OUT":"2015-04-25",
"RES_N_ADULTS":"6",
"RES_GUEST_FIRSTNAME":"Nicolas",
"RES_GUEST_LASTNAME":"Prantzos"
}

I want the RES_ID as autocomplete for the following input:

<input id="reservation_id" class="ui-autocomplete-input form-control" />

And when the input reservation_id will be filled take the rest RES_CHECK_IN and RES_CHECK_OUT and autofill them in

<input type="text" class="form-control" name="start">
<span class="input-group-addon">to</span>
<input type="text" class="form-control" name="end">

I tried to mix ajax + autocomplete do achieve that without any luck.

 (function autocomplete_search() {
        //this function take the @res_id input
        $("#reservation_id").autocomplete({
            source: "/police/get_res"
        });
    })();

How I show RES_ID as autocomplete and how i fill the rest of the inputs based on the RES_ID?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire