将 jQueryUI 变量传递给 PHP 输入

发布于 2024-12-16 21:51:37 字数 549 浏览 2 评论 0原文

好的,我已经修改 jQueryUI 对话框小部件了。我将其用作会员的消息传递服务。到目前为止,我所做的是让小部件继承收件人的真实姓名和用户名的值。剩下要做的唯一一件事就是将 userid 的值转移到某种事物中。大家可以看一下jsfiddle。 http://jsfiddle.net/pzByS/

[编辑] 我修好了jsfiddle。用户名是个人资料的链接。它会说,

<td class="realname">John Smith</td>
<td class="username"><a href=profile.php?uid=123>johnsmith</a></td>
<td><a href="#" class="opener">Send Message</a></td>

每个成员都会有所不同。应该如何将 uid 值传递给对话框小部件表单中的隐藏输入值?

Okay, so I've gotten this far in modifying the jQueryUI dialog widget. I'm using it as a messaging service for members. What I've done so far is for the widget to carry over values of both the Real Name and the username of the recipient. The only thing left to do is to carry over the value of the userid in a kind of thing. You can all have a look at the jsfiddle. http://jsfiddle.net/pzByS/

[EDIT]
I fixed the jsfiddle. The usernames are links to the profile. It would say,

<td class="realname">John Smith</td>
<td class="username"><a href=profile.php?uid=123>johnsmith</a></td>
<td><a href="#" class="opener">Send Message</a></td>

which will differ for every member. How should go in terms of passing the uid value to a hidden input value in the form for the dialog widget?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

他夏了夏天 2024-12-23 21:51:37

您需要使用其他占位符引用隐藏的表单元素。

//store reference to placeholders
    $realname = $('#realname'),
    $username = $('#username'),
    $uid = $('input[name=uid]');

然后在点击处理程序中;匹配用户名元素内链接的查询字符串中的用户 ID。

    $uid.attr('value',$row.find('td.username a').attr('href').match(/\?uid=(\d+)/)[1]); 

我已经在小提琴中对此进行了测试,它将根据您的要求使用用户的 id 填充隐藏的输入。

理想情况下,您应该分别从链接查询字符串中提取用户 ID,并在尝试用它填充表单元素之前对其进行一些健全性检查,但这应该足以让您继续下去。

You will need to reference the hidden form element with your other placeholders .

//store reference to placeholders
    $realname = $('#realname'),
    $username = $('#username'),
    $uid = $('input[name=uid]');

And then inside the click handler; match the user id from the query string of the link inside the username element as such.

    $uid.attr('value',$row.find('td.username a').attr('href').match(/\?uid=(\d+)/)[1]); 

I've tested this in the fiddle and it will populate the hidden input with the user's id as per your requirements.

Ideally you should extract the user id from the links query string separately and do some sanity checking on it before attempting to populate your form element with it, but this should be enough to get you going.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文