Skip to content Skip to sidebar Skip to footer

Html Forms - Input Type Submit Problem With Action=url When Url Contains Index.aspx

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:

Solution 1:

Put the query arguments in hidden input fields:

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

Solution 2:

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

Solution 3:

This appears to be my "preferred" solution:

<formaction="www.spufalcons.com/index.aspx?tab=gymnastics&path=gym"method="post"><div><inputtype="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:

<formaction="http://www.google.com"method="post"><div><inputtype="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!

Solution 4:

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.

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

Post a Comment for "Html Forms - Input Type Submit Problem With Action=url When Url Contains Index.aspx"