【问题标题】:Drop down form attached to button附加到按钮的下拉表单
【发布时间】:2014-01-28 07:11:34
【问题描述】:

我想将一个表单附加到一个按钮上,这样当按下按钮时,一个 from 将下拉到它的下方。我该怎么做这样的东西?

我没有提供任何代码,因为我认为除了回复我的问题的人发布的代码之外不需要任何代码,但是如果需要代码,我可以提供代码,但我认为不需要是。

感谢您阅读本文。

表格代码

<form action="team.php" method="POST" name="profiles">
<div>Team Name: <input type="text" name="team" value="<?php echo $cx;?>"></div>
<input type="submit" name="signupbtn">
</form>

按钮代码

<button class="myButtont"><?php echo "<a href=esports/create/team.php>Create a Team</a>";?></button>

你可能会想我为什么要回显一个链接。这是因为我会将数据库中的团队名称作为变量包含在内,所以请不要问我为什么要回显链接。

【问题讨论】:

  • 到表单和按钮?我根本没有尝试过,因为我不知道从哪里开始。我现在正在添加帖子
  • @Shivam 你是要回复还是浪费我的时间?
  • 抱歉回复晚了,我在某个地方很忙。

标签: forms button


【解决方案1】:

使用此代码,

<div id="div1" style="visibility:hidden;">
    <form action="team.php" method="POST" name="profiles">
    <div>Team Name: <input type="text" name="team" value="<?php echo $cx;?>"></div>
    <input type="submit" name="signupbtn">
    </form>
</div>

按钮代码,

<button class="myButtont" onclick='showForm();'><?php echo "<a href='#'>Create a Team</a>";?></button>

在您的 HTML 文件中使用此脚本,

<script>
function showForm() { 
   document.getElementById('div1').style.visibility= 'visible' ;
}
</script>

【讨论】:

  • 你太棒了。非常感谢你。我在想你让我发布代码是为了笑。再次感谢:)
  • 您的代码像梦一样工作,但是当表单被隐藏时,它会在表单所在的位置产生间隙。有没有办法让按钮基本上存储表单,直到它被点击,所以表单隐藏的地方没有间隙
【解决方案2】:

您可以使用弹出窗口来显示表单。您必须将按钮用作必须下拉的锚视图。更多你可以找到http://developer.android.com/reference/android/widget/PopupWindow.html

【讨论】:

  • 有没有办法让它下拉到按钮本身的下方?感谢您的评论,因为如果我无法从按钮下方下拉菜单,我将使用它
  • 嗯,我看到了你的安卓链接。这不只是为了移动使用吗?
猜你喜欢
  • 2013-12-28
  • 1970-01-01
  • 1970-01-01
  • 2016-05-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多