Note that there are some explanatory texts on larger screens.

plurals
  1. POGrab current value of textbox and drop-down-list and output them using jquery
    primarykey
    data
    text
    <p>What I would like to do is output the textbox value and the drop-down-list selected value simultaneously. The reason is I would like to eventually sort results through a mysql db table. Right now... when I change the textbox it will add onto the drop-down-list value, which is what I want. But when I change the drop-down-list value, it won't recognize the textbox value and revert to when the document was loaded as the value. How do I grab both values and echo them AND be able to change them and view the changes when I 'keyup' on the textbox or 'change' the drop-down-list value. Thanks in advance.</p> <p>jquery</p> <pre><code>$(document).ready(function () { var type_term = $("#type option:selected").text() var search_term = $("#search").val() $.post('search_db.php',{type_term:type_term, search_term:search_term}, function (data) { $('#search_results').html(data) }); $('#search').keyup(function() { var search_term = $("#search").val() $.post('search_db.php',{type_term:type_term, search_term:search_term}, function (data) { $('#search_results').html(data) }); }); $('#type').change(function() { var type_term = $("#type option:selected").text() $.post('search_db.php',{type_term:type_term, search_term:search_term}, function (data) { $('#search_results').html(data) }); }); }); </code></pre> <p>HTML</p> <pre><code>&lt;input id="search" type="text" value="Value"&gt; &lt;select id="type"&gt; &lt;option&gt;Type1&lt;/option&gt; &lt;option&gt;Type2&lt;/option&gt; &lt;/select&gt; &lt;div id="search_results"&gt;&lt;/div&gt; </code></pre> <p>searchdb.php</p> <pre><code>$type_term = $_POST['type_term']; $search_term = $_POST['search_term']; echo $type_term; echo $search_term; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload