0
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?

1

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());
1

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.

  • Can i know how can I do the same for a choice field to be populated from the same code? – Prashanth Edige Aug 30 '18 at 15:21
  • Using $('select[title="Origin Required Field"]').append("<option value='"+ArrivalCity+"'>"+ArrivalCity+"</option>"); – LZ_MSFT Aug 31 '18 at 1:46
0
$("input:text[title='Origin']").val(ArrivalCity);

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.