50r Posted November 21, 2012 Share Posted November 21, 2012 hello freaks i have a database table of tbl_menus (working on content management part of my script). menus are ordered according to the position in the table field position. on the site we have 4 spots for menus called modules but all menus are stored in one table tbl_menus we also have a field module in the table. now on the form in new menu.php the position will be based on the number of row based on the module field. the position select options are populated according to the number of row based on the module field. that mean while am creating a new menu, to populate the right number of row for someone to pick a position, i have to first run an sql count query base on a selection of the module. Javascript would be the base solution but how do i go about it? Quote Link to comment https://forums.phpfreaks.com/topic/270987-fire-up-a-php-code-based-on-a-selected-form-field/ Share on other sites More sharing options...
50r Posted November 21, 2012 Author Share Posted November 21, 2012 some where on google i saw this example but can someone try to break down for me cause i am failing to get it work. <script> function showDetails(id) { if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("details").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","test.php?q="+id,true); xmlhttp.send(); } </script> <select name="users" onchange="showDetails(this.value)"> <option value="">Select:</option> <option value="1">1</option> <option value="2">2</option> </select> <div id='details'></div> Quote Link to comment https://forums.phpfreaks.com/topic/270987-fire-up-a-php-code-based-on-a-selected-form-field/#findComment-1394122 Share on other sites More sharing options...
Muddy_Funster Posted November 21, 2012 Share Posted November 21, 2012 erm...perhaps the javascript forum would have been better? I did something simmilar just recently using PHP+JQueryUI to let members choose a default layout for portlets, and that code you have there looks to do nothing more than a simple ajax request to load content into a div depending on which option is picked, it doesn't communicate with anything that would preserve the info after page close. What I did only had 3 columns to handle, so I just defined a col_id of 0-3 in the table with 0 being not shown, 1 being left, 2 center and 3 right, then loaded the locations through a couple of loops. a static dropdown did for the location chooser in the account admin area to update which portlet went where. Quote Link to comment https://forums.phpfreaks.com/topic/270987-fire-up-a-php-code-based-on-a-selected-form-field/#findComment-1394128 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.