Frage

var ArrivalCity = (data.aircraftView[0].arcftSchedList[0].tripArrivalCity);
       $('input[title="Origin"]').val(ArrivalCity);

Here the origin is a single line text box field where I am populating the value from the rest api. I am able to retrive the value in ArrivalCity. But it is not putting the data in the Origin which is a single line text field. I tried different approaches but was not able to figure out. Can anyone help me with this?

War es hilfreich?

Lösung 3

$("input:text[title='Origin']").val(ArrivalCity);

Thank you for the answers. However the above code worked for me.

Andere Tipps

Your code (Setting the value to input field using JQuery) is correct, so try to investigate the issue as the following:

First, make sure that you have referenced the JQuery ref correctly.

Second, make sure that the title of the textbox is correct.

Third, make sure that the ArrivalCity log value console.log(ArrivalCity);

Fourth, convert the value to string ArrivalCity.toString(); at

$('input[title="Origin"]').val(ArrivalCity.toString());

If the Origin field is a required field, we need use the jQuery code below to set value.

$("input[title='Origin Required Field']").val(ArrivalCity);

I suggest you using IE or Chrome F12 developer tools to check this "input" html code and make sure the title name. And debug your code check if the ArrivalCity value is empty.

Or you can provide the full code for further research.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit sharepoint.stackexchange
scroll top