i want to get data from mysql db, first user select db, then enters id #
select db<select id="db" name="db_name">
<option value="">-choose-</option>
<option value="ekoloji_db">ekoloji</option>
<option value="ejobios_db">ejobios</option>
<option value="ejen_db">ejen</option>
</select><br/>
<table>
<tr><td> article id: <input id="articleID" type="text" name="Article_ID" size="3"/></td>
<td><div id="showarticle">
</div></td>
</tr></table>
i want to show article title after article id has been input, but with no page refresh. since i am newbie with jquery, i found .post() and implemented in a naive way,
$(document).ready(function(){
$("#db").change(onSelectChange);
});
function onSelectChange(){
var selected = $("#db option:selected");
var output = "";
output = selected.text() ;
$.post('db_connect.php', {db: "selected"}, function(show){
$("#showarticle").html(show);
});}
when db is selected from dropdown, it shows article title within showarticle div, but what i want is, make it visible after article id entered into textbox.
what comes from php is string, and i must post both dropdown value and aricle id, then show it. but i am stuck.
event sequence should be :
- user selects db from dropdown
- user input article ID
- just after article ID is entered, i want to show from selected db, selected article’s name..
any help is deeply appreciated..
Try this :
Docs for .blur() are here
You can use the
blurlistener and implement a function at the same time.I get the value from
thiswhich is the input and then the current selection (value) fromdbwhich is your select list. The post that data to the server.