如何进行多重选择来创建新行?
我有这样的代码:
<select name="team[]" size="8" multiple="multiple">$team</select>
它列出了该团队中的球员,我希望当用户单击球员时,它会创建一个新行,我可以在其中输入有关球员的基本信息,我将通过 php 将其添加到数据库中。
I have this code:
<select name="team[]" size="8" multiple="multiple">$team</select>
It lists for example players in that team, I want when user clicks on player it creates a new row where I can input basic info about player which I will add to database via php.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果我正确理解这个问题,这更多的是关于如何设计表格和编写 php,而不是 HTML 或 jQuery。
如果您有一个像这样的表:
和另一个像这样的表:
然后您可以将玩家拉出并填充组合框。您将生成的 HTML 如下所示:
然后,当您提交时,您可以使用类似这样的查询进行 sql 调用(您可能想要检查错误和 sql 注入,但这是一个简单的示例)
:这有帮助。如果这不能回答您的问题,请务必发布更多信息以便清楚起见。
If I understand this question correctly, this is more about how you design your table and write your php than the HTML or the jQuery.
If you have a table like this:
And another table like this:
Then you could pull the players out and populate the combo box. The HTML you would generate would be something like this:
Then, when you submit, you could do a sql call with a query something like this (you would want to check for errors and sql injection, but this is a simple example):
Hope this helps. If this does not answer your question, be sure to post more information for clarity.
我想是这样的,只是根据玩家的 id 或其他东西来调用。
$(文档).ready(function(){
});
something like this I suppose and just call based on an id or something for the player.
$(document).ready(function(){
});