CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    May 1999
    Posts
    87

    Action from Input Submit Button

    Can you have more than one Action from an Input Submit Button?
    If so, How is this done?

  2. #2
    Join Date
    Jul 2002
    Location
    Don't Know, Don't Care
    Posts
    346
    No,
    it's pretty much the same reason you can't have two bgcolor properties in the body tag, it will only accept one (if it accepts either, im not sure how it would handle that). Really, what you're doing when you say action= is setting a variable, if you do it twice you set it to either 2 different values, or only the second one will take precedence...once again im not sure how it works.
    Last edited by Waldo2k2; October 7th, 2002 at 07:11 AM.

    C G C F A D--Feel the Noise

    "When your life goes nowhere and leads back to me, doesn't that tell you something?"
    ~Gray Area Fury

  3. #3
    Join Date
    May 1999
    Posts
    87
    Yes, I see what you mean.
    I thought you could execute 2 or more actions sequentially.

  4. #4
    Join Date
    Aug 2002
    Location
    Reykjavik, Iceland
    Posts
    201
    When you say "more than one Action" do you mean that the <form> tag would have:

    <form name="foo" method="post" action="page1.jsp, page2.jsp">

    If so, then the answer is definitely no. But page1.jsp could call page2.jsp so you have the same effect.

    If by "more than one Action" you meant more than one operation- for example when the submit button was pressed, something was done on the client first, then the action was called. This can be done by calling a JavaScript function in the onSubmit event handler, which would be handled first before the action.

    If by "more than one Action" you meant could the action be variable? Then the answer is yes, as you could make the action depend on some server-side condition:

    <% if (goToPage1) { %>
    <form name="foo" method="post" action="page1.jsp">
    <% } else { %>
    <form name="foo" method="post" action="page2.jsp">
    <% } %>

  5. #5
    Join Date
    May 1999
    Posts
    87
    AAhh! All I really want to do is on the click of a button, I download three different file from my WEB space. I can do it now by having three buttons but I want to do it with one click and one button??

  6. #6
    Join Date
    Aug 2002
    Location
    Reykjavik, Iceland
    Posts
    201
    That's more like it. Why didn't you say so in the first place??

    Why not just make a ZIP file of the three files and have the action be to download the ZIP file?

  7. #7
    Join Date
    Jul 2002
    Location
    Don't Know, Don't Care
    Posts
    346
    some people don't have zip utilities...
    you can wrap everything into one function, i'm not sure how download requests work, i'll leave that part to you...but do this
    Code:
    //put this function in the onclick handler in your html
    function getEmAll()
    {
         //note: function names are substituted, i don't know what the real names are
         if (getFileFunction()==0)
         {
              //if it returns true, that means they got the first file, so do the next one
              if (getFileFunction()==0)
              {
                   if (getFileFunction()==0)
                   {
                         return true;
                    }
               }
          }
         else
         {
              return false;
          }
    }
    //returns true if it got through all three requests, false otherwise
    like i said that's not real code, but it's how you should set up yours

    C G C F A D--Feel the Noise

    "When your life goes nowhere and leads back to me, doesn't that tell you something?"
    ~Gray Area Fury

  8. #8
    Join Date
    Aug 2002
    Location
    Reykjavik, Iceland
    Posts
    201
    if (getFileFunction()==0) {
    //if it returns true, that means they got the first file, so do the next one
    if (getFileFunction()==0) {
    FYI.... In JavaScript, 1 is true and 0 is false. Replace the 0's with 1 (or true)!

    As for the download requests, you could just do a window.location and, depending on the mime type of the file, set the content disposition in the HTTP header.

  9. #9
    Join Date
    Jul 2002
    Location
    Don't Know, Don't Care
    Posts
    346
    wow...didn't know that javascript was the other way around with the one's and zero's....that explains a lot

    C G C F A D--Feel the Noise

    "When your life goes nowhere and leads back to me, doesn't that tell you something?"
    ~Gray Area Fury

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured