AJAX PHP function onchange select box

前端 未结 5 1835

I have a problem about which I am very confused. I have a select box with s dynamically generated using a mysqli query:

$result = mysqli_query($db, \"SELECT         


        
5条回答
  •  温柔的废话
    2021-01-16 23:18

    Your select box has no ID and you are watching the change event of $("#contacts").

    Change:

    echo '
    '; ^^^^^^^^^^^^^ here

    You also only need one event handler, so I have removed the inline one which doesn't seem to do anything anyway.

    Edit: If the select is created using ajax as well, you need event delegation:

    $("body").on('change', '#contacts', function() {
       ^^^^ for example
    

    Edit 2: Your variable is called $_REQUEST['option'] and not $_REQUEST['selectedValue']. You are also not calling your -badly named - function so you will not get any output from php except from an error like Parse error: syntax error, unexpected 'function' ....

提交回复
热议问题