Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 12 of 12
  1. #1
    New to the CF scene
    Join Date
    Dec 2009
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Input type="submit" with form action=URL that 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>
    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 --

  • #2
    Regular Coder
    Join Date
    Jun 2008
    Posts
    173
    Thanks
    2
    Thanked 9 Times in 9 Posts
    you need to give name to your submit button. try this below code

    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
    Last edited by vineet; 12-30-2009 at 05:22 AM.

  • #3
    New to the CF scene
    Join Date
    Dec 2009
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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....

  • #4
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Your code is close. You want something like this
    PHP Code:
    <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.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #5
    New to the CF scene
    Join Date
    Dec 2009
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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?

    Code:
    <a href="http://www.spufalcons.com/index.aspx?tab=gymnastics&path=gym">Gymnastics</a>
    Last edited by trentl4; 12-30-2009 at 03:05 PM.

  • #6
    New to the CF scene
    Join Date
    Dec 2009
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts
    This appears to be my "preferred" solution:
    Code:
    <form action="www.spufalcons.com/index.aspx?tab=gymnastics&path=gym" method="post">  
      <div>
        <input type="submit" value="Gymnastics">
      </div>
    </form>

  • #7
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Okay but this will work too then.

    Code:
    <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.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • Users who have thanked _Aerospace_Eng_ for this post:

    trentl4 (01-01-2010)

  • #8
    New Coder
    Join Date
    Dec 2009
    Posts
    82
    Thanks
    0
    Thanked 6 Times in 6 Posts

    submit

    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.

  • #9
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Default method is get not post, fyi.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #10
    New to the CF scene
    Join Date
    Dec 2009
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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 --

  • #11
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    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.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #12
    New to the CF scene
    Join Date
    Dec 2009
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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....

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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •