Jump to content

Displaying Member Details through a Combo Box.


theITvideos

Recommended Posts

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]

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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]

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

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]

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.