Rog
October 6th, 2002, 05:33 AM
Can you have more than one Action from an Input Submit Button?
If so, How is this done?
If so, How is this done?
|
Click to See Complete Forum and Search --> : Action from Input Submit Button Rog October 6th, 2002, 05:33 AM Can you have more than one Action from an Input Submit Button? If so, How is this done? Waldo2k2 October 7th, 2002, 07:09 AM 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. Rog October 7th, 2002, 09:58 AM Yes, I see what you mean. I thought you could execute 2 or more actions sequentially. websmith99 October 7th, 2002, 03:12 PM 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"> <% } %> Rog October 8th, 2002, 09:55 AM 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?? websmith99 October 8th, 2002, 10:37 AM 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? Waldo2k2 October 8th, 2002, 05:49 PM 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 //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 websmith99 October 9th, 2002, 06:58 PM 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. Waldo2k2 October 9th, 2002, 09:47 PM wow...didn't know that javascript was the other way around with the one's and zero's....that explains a lot :) codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |