lopes_andre Posted October 18, 2010 Share Posted October 18, 2010 Hi, I need to develop a code that allows me to choose how I want to see a list of data from the database. For example, I could choose to see "the most recent first" or "most recent last". I have this example on how work the "onChange" event: <html> <head> <title>Select Example</title> <script> function onSelectChange(){ var dropdown = document.getElementById("developer"); var index = dropdown.selectedIndex; var ddVal = dropdown.options[index].value; var ddText = dropdown.options[index].text; if(ddVal != 0) { output = "You Selected " + ddText; } document.getElementById("output").innerHTML = output; } </script> </head> <body> <h3>Developers</h3> <select id="developer" onChange="onSelectChange();"> <option value="0">the most recent first</option> <option value="1">the most recent flast</option> </select> <br / <div id="output"></div> </body> </html> Now I need to apply this to a SELECT from the database that will use this method to list data. I have tried to google it, but I can't find any example. Can someone give me a clue on how to find the way of doing this? Best Regards, Quote Link to comment Share on other sites More sharing options...
Colton.Wagner Posted October 18, 2010 Share Posted October 18, 2010 I am assuming you have no knowledge of ajax. Ajax makes it so you can access data without reloading a page. Basically you are going to need to use the ORDER BY mysql statement and send a variable through ajax so that a secondary php page can read it. I would reccomend moving this post to the General Discussion -> AJAX Help you will find a lot more helpful answers there. Thanks, Colton Wagner Quote Link to comment Share on other sites More sharing options...
objnoob Posted October 19, 2010 Share Posted October 19, 2010 You could look into doing the sorting client side. 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.