well basically what ajax is going to do is submit a post or get string as if you were submitting a form, and sit and listen for the results.
the prototype library takes care of all the logistics for you, really.
here is an example of a function i have in one of my pages:
Code:
function updater(itemid,form){
var itemupd = itemid;
new Ajax.Updater( itemid, 'func.php',
{ method: 'post', parameters: $(form).serialize()
} );
}
so your onChange statement would call the updater function like:
Code:
<select name='ptype' onChange=\"updater('results','formname');\" style='background-color:#CDBA96;'>
and what prototype will do is take the entire form you specify and submit it as a post string.
then on your processor php page you would treat it like any other form being submitted. the difference is that it's running in the background. your main page is sitting there listening and waiting for something to come back.
so on that processor page you could have a query:
PHP Code:
$conn = all your connection stuff here
if(ISSET($_POST['ptype'])){$itemid = strip_tags($_POST['ptype']);}
switch($itemid){
case 1:
$itemname = "whatever1";
break;
case 2:
$itemname = "whatever2";
break;
}
$query = 'SELECT `details_to_be_displayed` FROM `my_table` WHERE `my_item` = "'. mysql_real_escape_string($itemname) .'"'
$qresult = mysql_query($query, $conn);
while($result=mysql_fetch_array($qresult)){$details = $result['details_to_be_displayed'];}
echo $details;
and whatever is echo'd in details would be output in that target div. instead of using a switch based on the number of your choice you could straight up use the field name from your db as the id in the option, but it gives away a bit of your middleware logic.
now, i say all this assuming you're using stuff from a database.
there are other ways. if you want to have it all in your page you would just as easily hide\show div's or replace contents without ajax based on the id #. having the onChange call a function that checks the id and sets the innerHTML of the target div is easier, it just means you have to have the results hardcoded in the page instead of the db. if you want examples of that i can help there too.