Multiple Submits for a Single Form (Full Version)

All Forums >> [Web Development] >> ASP and Database



Message


Guest -> Multiple Submits for a Single Form (3/14/2001 20:31:00)

Anyone have an idea how to create a form in which a data from a single text box can be submitted to different queries (asp pages) using multiple submit buttons with different labels. I know I can do this by simply setting up several forms, but it's an inconvienence to the customer to have to type the same info into different fields....and it looks bad.

Thanks..





Vince from Spain -> RE: Multiple Submits for a Single Form (3/14/2001 20:28:00)

Hi Shmoop,
the first thing here is that what I would probably do in this circumstance is have ONE results page, but have different actions depending on the button pressed. The reason is that if you have the option of doing something client side or server side, normally best to choose server side.

So in the calling page you have
<input type="submit" name="mybutton" value="first">
<input type="submit" name="mybutton" value="second">

etc, and then in the results page
<% if request.form("mybutton") = "first" then %>
. . . all the html / asp to do with that one
<% elseif request.form("mybutton") = "second" then %>
. . . and all the html / asp to do with the second one
<% end if %>

But, if that is not a possibility then you can do what you want with a bit of javascript. For instance . . .

<HTML>
<HEAD>
<script language=javascript>
function gotopage(act) {
document.myform.action = act;
document.myform.submit();
}
</script>
</HEAD>
<BODY>
<form method="post" name="myform" action="doesntmatter.htm">
<A href="javascript:gotopage('page1.htm')"><IMG name="imgname" border="0" src="imgname.gif" ></a>
<input type="submit" name="button" value="hghgh" onclick="gotopage('page2.htm')">
</form>
</BODY>
</HTML>

I've put in one image button and one submit button to illustrate how to do it with either.

All the best

Vince

------------------
Internet Business Solutions S.L.(Spain)





Guest -> RE: Multiple Submits for a Single Form (3/14/2001 23:57:00)

Many thanks Vince,
The first method looks very nice as I can have only one results page for the plethora of queries that are normally generated in multiple asp pages. Of course, that is also an issue as I would need to take a bit of time to compile them all....so I opted for the second method which works perfectly and was easier to insert in all my pages. Time permitting, I want to try the other too!

Second question along the same lines....open to anyone...

One of my queries produces only one record...and I want to link the data from one of the fields in that record to a second query. One method is to use a hyperlink in the results of the first query....and I've used this method before. But because, it's only one record, I looks better if I just have a "Submit" button under the form results that when clicked, initiates the second query.

I tried:

<form method="POST" action="somequery.asp" >
<p><input type="Submit" value="MoreInfo" name="B1"></p>
<input type="hidden" name="Value name sent to second query" value="<%=FP_FieldVal("Value")%>">
</form>

Doesn't work....VBScript error....any ideas?





Spooky -> RE: Multiple Submits for a Single Form (3/14/2001 15:14:00)

Looks OK, is it within the region of the DRW code?

If it isnt (like so)

DRW start
fp_rs results
DRW End

Your form....

Then there is no way the asp cose will know what you mean by FP_FieldVal("Value")

This is a result that must be returned from with in the DRW boundaries

------------------
Spooky
"I am Spooky of Borg. Prepare to be assimilated, babycakes!"
Subscribe to OutFront News
Database / DRW Q & A
The Spooky Login!





Guest -> RE: Multiple Submits for a Single Form (3/14/2001 15:40:00)

Getting closer, I think.....

The only html on the asp page is the DRW followed by the form....so I think the form is within the DRW region.

At first I tried:
value="<%=FP_FieldVal(fp_rs,"Value")%>"
but it returned an error on "type mismatch 'rs'"

I tried removing the "fp_rs" to get:
value="<%=FP_FieldVal("Value")%>"
but returned an "Wrong number of arguments or invalid property assignment: 'FP_FieldVal'"

For kicks I tried removing just the "rs" to get:
value="<%=FP_FieldVal(fp_,"Value")%>"
but get an "Object missing"

I'm missing something somewhere....
I know this is getting a little over worked for a simple task, and I'm about ready to just put clickable image hyperlink to do the trick...but now I'm stubborn and want to know how to fix it!!





Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.046875