theITvideos Posted October 19, 2010 Share Posted October 19, 2010 Hi there... I am working on a PHP web form. I have Group name and its Member details stored in the database. The Group names from the database table gets populated in a combo box. Now what I'm trying to accomplish is, as soon I select a Group name, all its members should appear in a Label (or something) under the combo box with a textbox field next to the member name for me to assign the member position. How can we go about doing this. Please see the Screenshot I've attached and you'll have the idea as to what we're trying to accomplish here. All comments and feedback are welcomed! Thank you! [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/216287-displaying-member-details-through-a-combo-box/ Share on other sites More sharing options...
theITvideos Posted October 19, 2010 Author Share Posted October 19, 2010 Oops Sorry, here is the correct ScreenShot. Thank you Please I need your feedback. [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/216287-displaying-member-details-through-a-combo-box/#findComment-1124076 Share on other sites More sharing options...
objnoob Posted October 19, 2010 Share Posted October 19, 2010 1a. ) Send EVERY user to the webpage in a javascript array, and use that array to manipulate the dom based on selected group. (Not good for large user base, & must know javascript) 1b. ) Use AJAX to request the users of a selected group and manipluate the dom with the returned XML. (requires knowing XMLHttpRequest object, XML, and javascript) 2) When a group is selected 'onchange', submit form with selected group to the server and output a new page with members' names and textboxes. (Easiest but not seemless -- meaning you see a new page load) Quote Link to comment https://forums.phpfreaks.com/topic/216287-displaying-member-details-through-a-combo-box/#findComment-1124091 Share on other sites More sharing options...
theITvideos Posted October 20, 2010 Author Share Posted October 20, 2010 1a. ) Send EVERY user to the webpage in a javascript array, and use that array to manipulate the dom based on selected group. (Not good for large user base, & must know javascript) 1b. ) Use AJAX to request the users of a selected group and manipluate the dom with the returned XML. (requires knowing XMLHttpRequest object, XML, and javascript) 2) When a group is selected 'onchange', submit form with selected group to the server and output a new page with members' names and textboxes. (Easiest but not seemless -- meaning you see a new page load) Thank you for your reply. I was able to get the members detail of a Group using the 2nd method you suggested. Plus, a textbox (an input field) next to the member name for storing the member position. I am using the code to get members details: $memberInfo = getMember(array('GroupId' => $gId)); if ($memberInfo ) { foreach ($memberInfo as $info) { echo "<br/>". $info[memberName] . "<input name='txtMemberPosition' type='text' size='5' maxlength='5' />"; } } The output we get is shown in the Screenshot I took. It has a textbox next to the memberName. It works fine. Now I just need to store the details from these textboxes into the database. How do I read the textbox values? The textbox name is 'txtMemberPosition. But here we have over 3 textboxes displayed. How do I get the textbox values entered by user. Please reply. Thank you Please see the screenshot. [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/216287-displaying-member-details-through-a-combo-box/#findComment-1124542 Share on other sites More sharing options...
phpfreak Posted October 20, 2010 Share Posted October 20, 2010 I believe the answer was given above. You may want to look into jquery = http://jquery.com and use Javascript / Ajax to capture the state of the select menu - then pull the results from an Ajax script and populate your form fields using Javascript. PHP handles the processing as a pre-processor before your output is sent to the browser and there is nothing to do on the browser side once it's sent to your browser - therefore Javascript and AJAX will allow your application to be more interactive without loading up a new page each time a value changes. Quote Link to comment https://forums.phpfreaks.com/topic/216287-displaying-member-details-through-a-combo-box/#findComment-1124569 Share on other sites More sharing options...
theITvideos Posted October 22, 2010 Author Share Posted October 22, 2010 I believe the answer was given above. You may want to look into jquery = http://jquery.com and use Javascript / Ajax to capture the state of the select menu - then pull the results from an Ajax script and populate your form fields using Javascript. PHP handles the processing as a pre-processor before your output is sent to the browser and there is nothing to do on the browser side once it's sent to your browser - therefore Javascript and AJAX will allow your application to be more interactive without loading up a new page each time a value changes. Thank you for your reply. But my case is little different. As you can see in the Screenshot that the memberNames and the textboxes appear on the fly (at runtime) upon combo selection and I just need to somehow get the textbox values into a variable. The code I'm using to output memberInfo and textbox (for entering members position info) is: $memberInfo = getMember(array('GroupId' => $gId)); if ($memberInfo ) { foreach ($memberInfo as $info) { echo "<br/>". $info[memberName] . "<input name='txtMemberPosition' type='text' size='5' maxlength='5' />"; } } Here is the catch, every Group from the Combo has different number of members under it. Some have 3 members some have 5. Which means there will be 3 or 5 textboxes next to the members for me to type in the position. Now how do I get the values from the textbox. Please see the 2 Screenshots I've attached. Thank you [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/216287-displaying-member-details-through-a-combo-box/#findComment-1125063 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.