Showing results from select box
I have a select box like this,
I figured <form action="blah.php?do=products" method="post"> would work, but then it'd be going to a whole new page. What can I do? Thanks.
mmmmmkay... there are a couple ways to tackle this. ajax is probably what you want, because it'll update w\o needing a refresh. i don't claim to have the best way, but here is what you could do:
get the framework of your choice, for the sake of the example i'll say prototype
for this example you'll want to use the ajax updater that is built into prototype
it uses the following syntax:
new Ajax.Updater(container, url[, options])
the container is what will be updated, the url is your processor page. whatever it echo's first will be dropped into the container. under options you can set post, get, the actual paramters to be sent etc etc
below your select box you would have a target div or other container for updating. then you add an onChange event to your select statement.
i'd suggest really reading the options page. there is an absolute ton you can do, making this a very very powerful tool. the more i read the more i find. check out the entire api if you have time. it's pretty cool.
yell if i can be of further service, i have examples of usage and whatnot.
Wow you lost me on the Ajax thing, that is highly complex.
Will this code automaticly change the query results without a submit button?
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:
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:
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.
Now it's making a little more sense, I see some php in there, so that helps learn.
hey! this is exactly my problem.
could you please take a look and help me???
i'm stuck with it!!!
thanks in advance!!
|All times are GMT +1. The time now is 02:31 AM.|
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.