开发者

Looking how to send multiple values with an input type=submit form

Some background: I'm working on a member directory page which displays member information gathered from a MySqL database. I have a loop set to display name, id#, title, etc from each member - one member per row. The displayed member list can be searched and sorted so will be anywhere from 0-20 entries long (20 max per page).

Each member's name can be clicked and more information pertaining to them is displayed. For example, if the user clicks on "John Doe"'s name, an "individual info" page for John is included, splitting the list of names (the info is included directly after his name's listing, but before the next member's listing - ["John Doe, #333" / "Jane, #777"] turns into "John Doe, #333 / {John is a graduate from...}" / "Jane, #777"]).

I currently populate my page with PHP so the list is inside of a form and their names are displayed as inputs so when the user clicks them, the form action ($self) is run. I have the form value set to the member's name so that users can see readable names. I have the input's name set to the member's id# and run a if(isset($_POST['userID']) inside my loop to determine which member's individual information is displayed. So, the loop runs through the MySQL query, displaying name,id... for each member and if curID# == $_POST['userID'], it also displays the corresponding individual information.

My Issue: The problem I'm encountering is that my list is rather long on the page, especially with individual information displayed so I want to be able to jump to the member's info on the page using anchors corresponding to their ID#. I have the anchors set up, I can manually navigate to memList.php#ID333, but I want to navigate there when the user clicks on the name.

I can set up my form action to navigate to $self#$curID, but $curID is the variable name for the member's name input, not the value of it.

What Hasn't Worked: I've attempted hidden fields with their ID as the value and curiD as the name, but they do not work because my loop resets it for every member (hence, $_POsT['curid'] is always set to the bottom-most member, not the one the user clicked).

I've had the names as href links, but then my search and sort $POST values are not resent (the page is basically refreshed from the start).

My Question, Shorthand: Is there any way I can setup a开发者_开发问答n input field to display a member's name, yet have their ID sent as the value?


If I understood correctly, this sounds like something that would be best done using a javascript autocompleter. If you're using jQuery, here is a link to their autocomplete plugin. Check out the demo and see if this kind of approach suits your needs.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜