寻找如何使用输入类型=提交表单发送多个值 [英] Looking how to send multiple values with an input type=submit form

查看:112
本文介绍了寻找如何使用输入类型=提交表单发送多个值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

某些背景:我正在一个成员目录页面上,该页面显示从MySqL数据库收集的成员信息.我设置了一个循环,以显示每个成员的名称,id#,标题等-每行一个成员.显示的成员列表可以进行搜索和排序,因此可以在0-20个条目(每页最多20个)的范围内进行输入.

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).

可以单击每个成员的姓名,并显示与他们有关的更多信息.例如,如果用户单击"John Doe"的姓名,则将包含John的个人信息"页面,从而拆分姓名列表(该信息直接在其姓名列表之后,但在下一个会员列表之前- [" John Doe,#333"/" Jane,#777]变成了" John Doe,#333/{John毕业于...}"/" Jane,#777]).

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"]).

我当前使用PHP填充页面,因此列表位于表单内部,并且其名称显示为输入,因此当用户单击它们时,将运行表单操作($ self).我已将表单值设置为成员的名称,以便用户可以看到可读的名称.我将输入的名称设置为成员的id#,然后在循环中运行if(isset($ _ POST ['userID'])以确定要显示哪个成员的个人信息.因此,循环将通过MySQL查询运行,并显示名称,id ...对于每个成员,如果curID#== $ _POST ['userID'],则还会显示相应的个人信息.

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.

我的问题:我遇到的问题是我的列表在页面上很长,尤其是显示了个人信息,因此我希望能够使用对应于其ID#的锚点跳到页面上的成员信息. .我已经设置好锚点,可以手动导航到memList.php#ID333,但是当用户单击名称时,我想在此处导航.

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.

我可以将表单操作设置为导航至$ self#$ curID,但是$ curID是成员名称输入的变量名,而不是其值.

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.

未解决的问题:我尝试了将ID作为值,curiD作为名称的隐藏字段,但是它们不起作用,因为我的循环为每个成员重置了它(因此,$ _ POsT ['curid']始终设置为最底端的成员,而不是用户单击的那个成员.

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).

我已经将它们命名为href链接,但是然后我的搜索和排序$ POST值却没有重新发送(基本上从一开始就刷新了页面).

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).

我的问题,速记:有什么方法可以设置输入字段来显示成员的姓名,但将其ID作为值发送?

My Question, Shorthand: Is there any way I can setup an input field to display a member's name, yet have their ID sent as the value?

推荐答案

如果我正确理解,这听起来像是使用javascript自动完成程序最好完成的事情.如果您使用的是jQuery,则此处是其自动完成插件的链接.查看演示,看看这种方法是否适合您的需求.

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.

这篇关于寻找如何使用输入类型=提交表单发送多个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆