jamey8420 Posted March 3, 2010 Share Posted March 3, 2010 Hello, I have a php page that I am using AJAX to populate some check boxes based on a selection in a drop down box. Now, I'd like to expand that functionality to do something similar to this: http://www.dhtmlgoodies.com/scripts/multiple_select/multiple_select.html However, the troubling part is that I can have multiple groups of these select boxes; I am looping through a database selection to a heading for each group of select boxes, as well as the naming convention for each of the select boxes (left side would be alllistf1, alllist2, etc... and the right side would be sellist1, sellist2, etc...) and incrementing the variables each time through the loop (which then gives me the distinct names for each of the list boxes). $cc_res = mssql_query("SELECT clnum, clname + ' (' + clnum + ')' as cc FROM cost_center_clnum order by clnum"); $numberofrows=mssql_num_rows($cc_res); //echo $numberofrows."<br>"; $alllistvar = $numberofrows/$numberofrows; $selectlistvar = $numberofrows+1; while($row=mssql_fetch_array($cc_res)){ $ccid = $row['clnum']; $cc = $row['cc']; echo " <span class='f2'>".$cc."<br></span>"; The end results would be something like this: Heading1 List 1 List 3 Heading 2 List 2 List 4 with Lists 1 and 2 being possible rights for a user and lists 3 and 4 being the rights currently assigned to that user. When a user is selected in the drop down box, I'd like to populate List boxes 3 and 4 with the respecitve persons's rights. A bonus would be to populate list boxes 1 and 2 with all rights that are not currently selected, instead of all of the rights. Since I don't have the names of the headings and list boxes hard coded into the page, I'm not sure how I can pass back the resultant values into the list boxes with AJAX. Any help on this would be greatly appreciated. If you need any clarification don't hesitate to ask. Thanks for all your thoughts. Quote Link to comment Share on other sites More sharing options...
jamey8420 Posted March 10, 2010 Author Share Posted March 10, 2010 I ended up coming to a solution on this. I was able to create a php file for each of my select boxes; not totally what I wanted to do but it gets the job done. In the php file, I am doing a select of the database to determine if it's a right of the user, and if so I display it back to my original form like so: echo "obj.options[obj.options.length] = new Option('".$codedesc."', '".$index."');\n"; 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.