通过多个链接发布或获取多个值
我是新手,所以请耐心等待...
我希望能够使用链接将多个变量传递到另一个页面,例如:
<a href="value1">some text</a>,<a href="value2">some text2</a>,<a href="value3">some text3</a>,<a href="value4">some text4</a>
我希望能够将其用作“多重选择器”,以便用户将能够单击(选择)他们想要的任何文本,并以某种方式使用提交按钮通过 post 或 get 发送这些选定的值。
我不想使用菜单或列表,因为我试图显示文本,并且每个链接包含文本的不同部分,例如章节中的段落,因此用户会单击一个段落(这是一个链接,或者至少看起来像一个)并将其值发送到其他页面,但是我想要多个段落,以便用户能够选择段落,如果可能的话取消选择段落。
如果可能的话希望有人能指出我正确的方向
I'm new with this so please be patient with me...
I want to be able to pass multiple variables to another page using links, for example:
<a href="value1">some text</a>,<a href="value2">some text2</a>,<a href="value3">some text3</a>,<a href="value4">some text4</a>
I want to be able to use this as "multi-selector" so that the user would be able to click (select) what ever text they want and somehow with a submit button send those selected values via post or get.
I don't want to use a menu or list as I'm trying to show text and each link holds different parts of the text, kind of parragraphs in a chapter, so the user would click a paragraph (wich is a link, or at least looks like one) and send it's value to other page, however I want multiple parragraphs so that the user would be able to select and if possible unselect paragraphs.
Hope someone would point me to the right direction if possible
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
以下是我可能如何实现这一点:
HTML:
Javascript:
(我在上面使用地图而不是数组,以避免每次点击时都必须遍历数组)
http://jsfiddle.net/5y7wK/
Here's how I might go about implementing this:
HTML:
Javascript:
(I use a map rather than an array in the above to avoid having to traverse an array on every click)
http://jsfiddle.net/5y7wK/
传递多个值的最佳方法是通过表单提交或 AJAX 请求,您可以有多个复选框,以便当用户选择所需的值然后在单个请求中发送它们时。
这是一个示例:示例
The best way to pass multiple values is through a form submission or an AJAX request, you could have multiple check boxes so that when the user selects the values it wants and then sends them in a single request.
Heres a sample : Sample