MySQL Forums
Forum List  »  PHP

Re: Problem with populating Dropdown Menu with PDO
Posted by: Frank Olschewski
Date: December 13, 2015 01:00PM

Hey,

I tried to create the dropdown (for now without connection to the db) with help from the code-snippets from some videos and other input, but I just don't get why it isn't working (please keep in mind that I'm really not too experienced).

This is the code I use on the request.php page where the dropdown and the dynamic content should be displayed:

<form name="request" action="request.php" method="post">
<p>How many subjects are requested? <br />
<select name="nrsubjects" id="user-select">
<option value="1">1 subject</option>
<option value="2">2 subjects</option>
</select>
</p>
</form>

<div id="user-profile"></div>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>;
<script src="js/global.js"></script>


And here the partials/user.php with the input that should be shown on the request.php:

<?php
if (isset($_GET['nrsubjects'])){
echo "TEST TEST ". $_GET['nrsubjects'];
}
?>

And the global.js file with the ajax:

$('#user-select').on('change', function() {
    var self = $(this);

    $.ajax({
        url: 'https://www.xxx.de/partials/user.php';,
        type: 'GET',
        data: { user: self.val() },
        success: function(data){
          $('#user-profile').html(data);
        }
    });
});

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.