CincoPistolero Posted February 28, 2009 Share Posted February 28, 2009 I have a page that makes a list based on all open tickets. I'd like to have a dropdown on that page that users can make a selection and then the page refreshes with either just their open tickets, are all their closed tickets or both. I can figure out all the different db select statements to display the different data, but I'm confused on how to run the dropdown box. I'd like to stick with PHP and not do any javascript. Can anyone point me towards a tutorial or make suggestion, like: use switch statements or if/else. Can I do something like this in PHP <form action="" method="post" name="pageView" > <select name="viewList" onchange="OnChange(this.form.viewList);"> and have this call a function Signed, Confused Quote Link to comment https://forums.phpfreaks.com/topic/147243-need-data-to-change-on-page-when-dropdown-selection-is-made/ Share on other sites More sharing options...
RussellReal Posted February 28, 2009 Share Posted February 28, 2009 you'd need to use javascript.. but include a button somewhere under or to th eside of the button incase a user has disabled JavaScript.. but you'd do something like this: <script type="text/javascript"> function _switch(obj) { //either submit the form (which you could do from onChange .submit() // or set the new url manually.. top.location = "http://new.url.com/?whatever="+obj.value; } </script> <select name="whatever" onChange="_switch(this)"> <option value="1">Whatever</option> </select> Quote Link to comment https://forums.phpfreaks.com/topic/147243-need-data-to-change-on-page-when-dropdown-selection-is-made/#findComment-772964 Share on other sites More sharing options...
CincoPistolero Posted February 28, 2009 Author Share Posted February 28, 2009 Based on which selection is made, a new call to the database will need to be made. Can that be done from within a javascript switch statement. does PHP have an onchange or should I call a class file each time and the db call made is based on the value of the dropdown? Can the page then update itself? Quote Link to comment https://forums.phpfreaks.com/topic/147243-need-data-to-change-on-page-when-dropdown-selection-is-made/#findComment-772970 Share on other sites More sharing options...
samshel Posted February 28, 2009 Share Posted February 28, 2009 U need AJAX. try googling around, lot of help available for that, Quote Link to comment https://forums.phpfreaks.com/topic/147243-need-data-to-change-on-page-when-dropdown-selection-is-made/#findComment-772974 Share on other sites More sharing options...
Stephen68 Posted February 28, 2009 Share Posted February 28, 2009 Ya read the Ajax tut in the forum here it's great and easy to use. http://www.phpfreaks.com/forums/index.php/topic,115581.0.html Quote Link to comment https://forums.phpfreaks.com/topic/147243-need-data-to-change-on-page-when-dropdown-selection-is-made/#findComment-772985 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.