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? There are any examples? Best Regards, Quote Link to comment https://forums.phpfreaks.com/topic/216191-how-to-use-onchange-in-a-dropdown-box/ 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.