/    Sign up×
Community /Pin to ProfileBookmark

Input type-submit with form action=URL which contains index.aspx

I have a HTML form that truncates the action URL parameter after the question mark symbol – which is NOT the desired behavior I am looking for. I simply want to open the referenced URL within the same viewport.

[CODE]
<form action=”www.spufalcons.com/index.aspx?tab=gymnastics&path=gym”>
<input type=”submit” value=”Gymnastics”/>
</form>
[/CODE]

In this case, the submit button takes you to the index.aspx page, effectively ignoring the parameters after the question mark. It appears that URL’s using HTML and PHP pages referenced in the a work as expected BUT (alas) this is not the case when the target page contains index.aspx. Cut and paste of the full URL into the toolbar brings me to the correct webpage. 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

TIA —

to post a comment
HTML

7 Comments(s)

Copy linkTweet thisAlerts:
@justinbarneskinDec 30.2009 — just off the top of my head, ok?


<form [I]action="http://www.spufalcons.com/index.aspx?tab=gymnastics&path=gym"></form> [/I]
[code=html]

<form onSubmit="location='http://www.spufalcons.com/index.aspx?tab=gymnastics&path=gym'; return false">
<input type="submit" value="Gymnastics"/>
</form>
[/code]
Copy linkTweet thisAlerts:
@trentl4authorDec 30.2009 — (OnSubmit) worked but requires Javascript to be enabled. Any idea on how to do this without Javascript?
Copy linkTweet thisAlerts:
@FangDec 30.2009 — &lt;form action="http://www.spufalcons.com/index.aspx" method="get""&gt; <br/>
&lt;div&gt;
&lt;input type="hidden" name="tab" value="gymnastics"&gt;
&lt;input type="hidden" name="path" value="gym"&gt;
&lt;input type="submit" value="Gymnastics"&gt;
&lt;/div&gt;
&lt;/form&gt;
Copy linkTweet thisAlerts:
@trentl4authorDec 30.2009 — Your suggestion to use hidden input fields definitely resolved this immediate issue for me. Thank YOU! But it brings up another "challenge"....

I will have a substantial number of external URL's that will be maintained and updated in a MySQL database - there may be anywhere from one to four variable "get" parameters that would need to be parsed from the URL string and then defined as hidden input fields for each URL. This complexity may be necessary to preserve the button behavior. Could there be a way to "wrap" an anchor/HREF declaration inside the form element (either the action or input attributes) in order to make this parsing unnecessary?

Here is an HREF declaration that does "the same thing":
[CODE]
<a href="http://www.spufalcons.com/index.aspx?tab=gymnastics&path=gym">Gymnastics</a>
[/CODE]


My primary goal is to keep the button while at the same time simplifying the underlying code.

TIA --
Copy linkTweet thisAlerts:
@trentl4authorDec 30.2009 — 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>

</form>
Copy linkTweet thisAlerts:
@jonmasterDec 31.2009 — it is necessary to mention the method

<form action="http://www.spufalcons.com/index.aspx?tab=gymnastics&path=gym" method="post">


<input type="submit" value="Gymnastics"/>

</form>
Copy linkTweet thisAlerts:
@Samwho_Dec 31.2009 — Yes, indeed ? It is also a good idea to include to http:// in your action attribute (if you're linking offsite, that it. If you're linking to you own server then there is no need to include your host name).

Also, on hidden forms: I wouldn't use them. It is VERY easy to edit the values in hidden HTML fields and thus opening you up to various types of injection. That being said, it's also possible to edit the "action" attribute so I urge you to make sure you're properly sanitising your POST/GET variables ?
×

Success!

Help @trentl4 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.21,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...