fisher7679 Posted September 30, 2013 Share Posted September 30, 2013 To be honest I am sure this is something simple that I am missing or just not understanding. What I am trying to do is use a dropdown menu to make a selection to search a db and display the results. The php portion works fine as I have hard coded the search criteria into it and it displays the results just fine. I can also use a plain text box and type the search string in with it displaying the results as well. Just not sure what I am doing wrong on the dropdown menu form/ Here is the for code I am using. <html> <head> <title>Untitled Document</title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript"> function get() { $('#data').hide(); $.post('data.php', { name: form.name.value }, function (output) { $('#data').html(output).fadeIn(1000); }); } </script> </head> <body bgcolor="#2E64FE"> <p></p> <p></p> <form action=""><select name="genetics"> <option value="Item1">Item1</option> <option value="Item2">Item2</option> <option value="Item3">Item3</option> <option value="Item4">Item4</option> </select><input type="hidden" name="option value" /> <input type="button" value="Search" onclick="get();" /> <div id="data"></div> </form> </body> </html Any help or direction would be great, Thanks in advance! Quote Link to comment Share on other sites More sharing options...
Solution Ch0cu3r Posted September 30, 2013 Solution Share Posted September 30, 2013 The line here $.post('data.php', { name: form.name.value }, Specifically the form.name.value part is looking for a form with the id of form and a field within that form named as name. This is how you'll get the selected value from the select menu using JQuery. $.post('data.php', { name: $('select[name=genetics]').val() }, Quote Link to comment Share on other sites More sharing options...
fisher7679 Posted September 30, 2013 Author Share Posted September 30, 2013 Thank you! That worked to fix it and also helps me to understand how to do it again in the future. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.