JavaScript How to show value which get from database in select option show that value of g decreases with height

I would like to show value in select option which value was query from database. And this value should be use in another functions, not to show only.

This is html script with JQM.

<div data-role="fieldcontain" class="ui-field-contain">
    <label>Priority : </label>
    <select name="priority" id="idPriority">
        <option value=""></option>
        <option value="High">High (3days)</option>
        <option value="Low">Low (5days)</option>
    </select>
</div>

This is jQuery script.

function functionSuccess(data){
    var eachrow = JSON.parse(data);
    $('#idPriority').val(eachrow[0].logPriority);    //This line is not work
}

PS.I use Ajax and PHP to get data from database. And I'm sure that data come already because I have tested to show value in input textbox and no problems.

PS.I don't use append() because it cannot use to define value. It can show data only.

Answer:1

You can set only those value to dropdown which are already in option so you can set "", High and Low value only. If you tried to set any other value than these E.g Test then it will not work.

var myResponse = [{"logPriority":"High"}];
$( document ).ready(function() {
    $('#idPriority').val(myResponse[0].logPriority);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div data-role="fieldcontain" class="ui-field-contain">
    <label>Priority : </label>
    <select name="priority" id="idPriority">
        <option value=""></option>
        <option value="High">High (3days)</option>
        <option value="Low">Low (5days)</option>
    </select>
</div>
Answer:2

I am using ReactJs to develop my application. I am trying to submit an input text when Enter is pressed by handling the onKeyPress event. It detects other inputs, but not enter. I have tried different ...

I am using ReactJs to develop my application. I am trying to submit an input text when Enter is pressed by handling the onKeyPress event. It detects other inputs, but not enter. I have tried different ...

  1. detect magic 5e
  2. detect language
  3. detect thoughts 5e
  4. detect magic
  5. detect synonym
  6. detect definition
  7. detect magic pathfinder
  8. detect good and evil 5e
  9. detect thoughts
  10. detect meaning
  11. detect font
  12. detect life skyrim
  13. detect evil pathfinder
  14. detect poison and disease
  15. detect cycle in directed graph
  16. detect pokemon
  17. detect vs protect
  18. detect hidden camera
  19. detect magic 3.5
  20. detect font from image

After setting up a webpack build with uglify, one wants to know how effectively the modules are being compressed, so it can be optimized. Is there any tooling for this? I don't see webpack or uglify ...

After setting up a webpack build with uglify, one wants to know how effectively the modules are being compressed, so it can be optimized. Is there any tooling for this? I don't see webpack or uglify ...

I have a webpage that calls an AJAX script - ajax.php. I am using JQuery to send the AJAX requests. The script ajax.php receives some arguments via$_REQUEST, based on that it starts its processing. ...

I have a webpage that calls an AJAX script - ajax.php. I am using JQuery to send the AJAX requests. The script ajax.php receives some arguments via$_REQUEST, based on that it starts its processing. ...

  1. jquery ajax incremental response
  2. jquery ajax increment

So i have a dynamodb table called tableX with the fields: random_fld1, random_fld2, primary_key1, and sort_key1 all fields are Strings. What would be a getItem example with those keys and fields. I ...

So i have a dynamodb table called tableX with the fields: random_fld1, random_fld2, primary_key1, and sort_key1 all fields are Strings. What would be a getItem example with those keys and fields. I ...