0

For a normal text box I wrote this:

$SUL("#txtlinkid").val(json[0].linkurl);

The information is prefilling automatically from the database.

For a dropdown I wrote this:

$SUL("#txteventitleid").val(json[0].eventtitle);

But it is not prefilling from the database.

What is the correct procedure for dropdown?

4
  • If the object with id txteventitleid is a dropdown (select) then it will not work. to fill the select with options you can look at stackoverflow.com/a/1745745/2943218 It's simular but you need to change it just a bit Commented Jun 14, 2022 at 11:07
  • 1
    For the dropdown, are you trying to select a value, or add all options to it? Commented Jun 14, 2022 at 11:08
  • 2 questions: 1) what is the HTML for your "dropdown" - you've named it with prefix txt which indicates it's a textbox, not a select. 2) exactly what is the ID of the "dropdown"? Your property is eventtitle, but your code ID is eventitleid - looks like it should be eventtitleid (2 Ts in the middle). This is why we ask for minimal code - looks like it's just a typo. Commented Jun 14, 2022 at 11:15
  • If the <option>s already exist and it is a <select id='eventitleid> then $("#txteventitleid").val(new_value) should work, here's an example: jsfiddle.net/msuedwnc but it won't add new <option>s for you. Commented Jun 14, 2022 at 11:17

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.