...

View Full Version : Input type="submit" with form action=URL that contains index.aspx



trentl4
12-30-2009, 04:37 AM
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.



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


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 --

vineet
12-30-2009, 04:50 AM
you need to give name to your submit button. try this below code



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


vineet

trentl4
12-30-2009, 06:04 AM
Do you mean PHP's http_redirect command?(http://www.php.net/manual/en/function.http-redirect.php)

This is intended to handle http 30X-type errors. I am simply trying to access a (good) URL external to my webpage. The problem arises when the target URL is an index.aspx - somehow the URL in the action= section of my HTML <form> is being truncated. URL's ending in .html or .php or .com/ work as expected with no problem....

_Aerospace_Eng_
12-30-2009, 08:30 AM
Your code is close. You want something like this

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

The key part of this is method="get" which is the default. Also you had no http:// in front of your code url either. The above works.

trentl4
12-30-2009, 03:00 PM
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?



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

trentl4
12-30-2009, 03:21 PM
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>

_Aerospace_Eng_
12-30-2009, 09:14 PM
Okay but this will work too then.


<a href="http://www.spufalcons.com/index.aspx?tab=gymnastics&amp;path=gym">Gymnastics</a>
There is no need for the form at all. Just task on the other items to the query string. I suggest using &amp; instead of & because it makes the link valid according to w3c.

harrierdh
12-30-2009, 09:15 PM
fix your form tag to include method="get", your probably getting a default method of "post". that could be why the hidden field worked and the query string did not.

_Aerospace_Eng_
12-30-2009, 09:15 PM
Default method is get not post, fyi.

trentl4
12-30-2009, 10:36 PM
Aerospace_Eng,

I haven't found a good way to embed the href "inside" the form's submit button so that it behaves like the form's action attribute. This would potentially allow me to avoid having to put in some conditional code to test the URL to determine whether get or post should be used.

TIA --

_Aerospace_Eng_
12-31-2009, 12:35 AM
Okay but you are missing the point. The only thing your form does is submit to that url and at the same time redirects to that url however just clicking a link will do the same thing. That url takes in get variables. There is NO need for the form just use a link.

trentl4
01-01-2010, 10:05 PM
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 + eliminates the get/post complexity associated with using a form-based approach. Thanks so much for the input....



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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum