Can you have more than one Action from an Input Submit Button?
If so, How is this done?
Printable View
Can you have more than one Action from an Input Submit Button?
If so, How is this done?
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.
Yes, I see what you mean.
I thought you could execute 2 or more actions sequentially.
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">
<% } %>
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??
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?
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
like i said that's not real code, but it's how you should set up yoursCode://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
FYI.... In JavaScript, 1 is true and 0 is false. Replace the 0's with 1 (or true)!Quote:
if (getFileFunction()==0) {
//if it returns true, that means they got the first file, so do the next one
if (getFileFunction()==0) {
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.
wow...didn't know that javascript was the other way around with the one's and zero's....that explains a lot :)