HTML 表单 - 当 URL 包含 index.aspx 时,使用 action=URL 输入类型提交问题

发布于 2024-08-15 21:11:12 字数 961 浏览 3 评论 0原文

我有一个 HTML 表单,它会截断“?”之后的操作参数。标记 - 这不是我正在寻找的理想行为。

下面是一个代表性的 HTML 片段:

<form action="http://spufalcons.com/index.aspx?tab=gymnastics&path=gym">
    <input type="submit" value="SPU Gymnastics"/>
</form>

在本例中,提交按钮会将您带到“http://www.spufalcons.com/index.aspx”。 spufalcons.com/index.aspx”页面,有效忽略“?tab=gymnastics&path=gym”参数。看起来,action=URL 中引用的所有 HTML 和 PHP 页面都按预期工作。此行为在所有主要浏览器(IE、FF、Safari、Chrome、Opera)中都是一致的。

以前有人见过这个问题吗?或者可以建议与我的“纯”CSS/HTML/PHP Web 开发方法一致的替代方案和/或解决方法?我尝试用 HTML 实体值替换特殊字符,但没有任何影响。我真的不想通过使用 Javascript 或按钮 PNG 或图像映射来放弃我的 CSS 样式提交按钮。

环境:

  • Web 服务器:Apache 2.2.14
  • PHP:5.2.10
  • 操作系统:Mac OS X 10.5.8
  • HTML 文档信息:

  • "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

TIA -- 特伦特

I have a HTML form that truncates the action parameter after the "?" mark - which is NOT the desired behavior I am looking for.

Here is a representative HTML snippet:

<form action="http://spufalcons.com/index.aspx?tab=gymnastics&path=gym">
    <input type="submit" value="SPU Gymnastics"/>
</form>

In this case, the submit button takes you to the "http://www.spufalcons.com/index.aspx" page, effectively ignoring "?tab=gymnastics&path=gym" parameter. It appears that all HTML and PHP pages referenced in the action=URL work as expected. This behavior is consistent across all major browsers (IE, FF, Safari, Chrome, Opera).

Has anyone seen this problem before? Or can suggest an alternative and/or workaround consistent with my "pure" CSS/HTML/PHP web development approach? I have tried replacing the special characters with HTML entity values with no impact. I REALLY don't want to use abandon my CSS-styled submit buttons by using Javascript or button PNG's or image maps.

Environment:

  • Web Server: Apache 2.2.14
  • PHP: 5.2.10
  • OS: Mac OS X 10.5.8
  • HTML document info:
  • <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">

TIA --
Trent

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

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

发布评论

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

评论(4

记忆里有你的影子 2024-08-22 21:11:12

将查询参数放入隐藏的输入字段中:

<form action="http://spufalcons.com/index.aspx">
    <input type="hidden" name="tab" value="gymnastics" />
    <input type="hidden" name="path" value="gym" />
    <input type="submit" value="SPU Gymnastics"/>
</form>

Put the query arguments in hidden input fields:

<form action="http://spufalcons.com/index.aspx">
    <input type="hidden" name="tab" value="gymnastics" />
    <input type="hidden" name="path" value="gym" />
    <input type="submit" value="SPU Gymnastics"/>
</form>
就是爱搞怪 2024-08-22 21:11:12

使用method=POST那么它将传递key&value。

Use method=POST then it will pass key&value.

风为裳 2024-08-22 21:11:12

这似乎是我的“首选”解决方案:

<form action="www.spufalcons.com/index.aspx?tab=gymnastics&path=gym" method="post">  <div>
<input type="submit" value="Gymnastics"></div>

抱歉,演示文稿格式 - 我仍在尝试学习如何使用此论坛......

我确实有一个后续问题。在查看我的 URL 的 MySQL 数据库时,似乎有大约 30% 的 URL 需要使用这种 post/div 包装器方法。这使得大约 70% 的人无法接受“post”属性。例如:

<form action="http://www.google.com" method="post">
  <div>
    <input type="submit" value="Google"/>
  </div></form>

不起作用。您对如何最好地处理此获取/后条件测试有建议吗?我突然想到使用 PHP 来评估“?”的存在性。 URL 中的字符可能是我最好的方法,尽管我不确定如何构建 HTML 表单来实现此目的。

谢谢你!

This appears to be my "preferred" solution:

<form action="www.spufalcons.com/index.aspx?tab=gymnastics&path=gym" method="post">  <div>
<input type="submit" value="Gymnastics"></div>

Sorry for the presentation format - I'm still trying to learn how to use this forum....

I do have a follow-up question. In looking at my MySQL database of URL's it appears that ~30% of the URL's will need to use this post/div wrapper approach. This leaves ~70% that cannot accept the "post" attribute. For example:

<form action="http://www.google.com" method="post">
  <div>
    <input type="submit" value="Google"/>
  </div></form>

does not work. Do you have a recommendation for how to best handle this get/post condition test. Off the top of my head I'm guessing that using PHP to evaluate the existence of the "?" character in the URL may be my best approach, although I'm not sure how to structure the HTML form to accomplish this.

Thank YOU!

囚你心 2024-08-22 21:11:12

我将 CSS 样式应用于锚定的 HREF 属性,完全模拟我需要的按钮行为(悬停、活动、背景颜色等)。 HTML 标记要简单得多,并且消除了与使用基于表单的方法相关的 get/post 复杂性。

<a class="GYM" href="http://www.spufalcons.com/index.aspx?tab=gymnastics&path=gym">Gymnastics</a>

I applied CSS styling to an anchored HREF attribute fully emulating the push button behaviors I needed (hover, active, background-color, etc., etc.). HTML markup is much simpler a-n-d eliminates the get/post complexity associated with using a form-based approach.

<a class="GYM" href="http://www.spufalcons.com/index.aspx?tab=gymnastics&path=gym">Gymnastics</a>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文