HTML forms - input type submit problem with action=URL when URL contains index.aspx

Trent picture Trent · Dec 29, 2009 · Viewed 108.7k times · Source

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

Answer

Gumbo picture Gumbo · Dec 29, 2009

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>