html表单内容和css对齐问题

发布于 12-17 17:11 字数 1066 浏览 2 评论 0原文

我有一个带有提交按钮和取消按钮的用户注册表单,

问题 1) 如果我在表单中使用 提交按钮,当我单击取消按钮时,它执行表单的操作,而不是返回主页并取消注册页面。

我们不能将这两个按钮放在一个表单中吗?

问题2)由于问题1,我在表单外部添加了取消按钮并链接到主页,它按我的预期工作,但是,我需要这些屏幕同一行中的两个按钮

<div id="main-content">
    <div id="login-container">
        <form id="user-registration-form" method="POST">
            // Some other fields, like username, etc.
            <fieldset class="edit" id="submit-button-fieldset">

                <input type="submit" id="submit-regiser"/>

            </fieldset>

        </form>
        <fieldset id="Cancel-field">
          <button id='cancel-registration' onclick=window.location.href='link-to-home'>Cancel</button>
        </fieldset>
      </div>
  </div>

我需要将这些 #submit-regiser#cancel-registration 放在屏幕的同一行中。这是针对移动浏览器的,因此应该遵守 XHTML 规则

提前致谢。

I have a user registration form with a submit button and a cancel button,

Problem 1) I can't have those two buttons inside the single form, if I have the cancel button inside the form with submit button, when I click the cancel button, it execute the action of the form instead of going to home and cancelling the registration page.

Can't we have these two buttons inside a single form..?

Problem 2) Because of Problem 1, I added the cancel button outside the form and linking to the home page, it works as I expect, but, I need to have those two button in the same row on the screen.

<div id="main-content">
    <div id="login-container">
        <form id="user-registration-form" method="POST">
            // Some other fields, like username, etc.
            <fieldset class="edit" id="submit-button-fieldset">

                <input type="submit" id="submit-regiser"/>

            </fieldset>

        </form>
        <fieldset id="Cancel-field">
          <button id='cancel-registration' onclick=window.location.href='link-to-home'>Cancel</button>
        </fieldset>
      </div>
  </div>

I need to have those #submit-regiser and #cancel-registration in the same row in the screen. And this is for mobile browser, so should obey XHTML rules

Thanks in advanced.

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

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

发布评论

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

评论(1

扎心2024-12-24 17:11:15

这就是预期的行为。取消按钮应该清除表单,而不是返回到之前的页面。

您仍然可以使用

<form id="user-registration-form" method="POST">
    <fieldset class="edit" id="submit-button-fieldset">
        <button type="submit" id="submit-regiser">submit</button>
        <button id="cancel-regiser" onClick="window.location.href='http://example.com'; return false;">Back</button>
    </fieldset>
</form>

That's the intended behavior. Cancel buttons are supposed to clear the form, not to take one back to what page ever.

Still you can do it this way using the <button> element:

<form id="user-registration-form" method="POST">
    <fieldset class="edit" id="submit-button-fieldset">
        <button type="submit" id="submit-regiser">submit</button>
        <button id="cancel-regiser" onClick="window.location.href='http://example.com'; return false;">Back</button>
    </fieldset>
</form>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文