Solved

One Page with 3 form submits?

Posted on 2007-11-30
10
160 Views
Last Modified: 2010-04-21
I'm trying to create a pure html page that will take an input value (entered by the user) and then, upon a Button click, pass the value to an ASPX.net page on the query line. I need this ability to appear three times on the same html page and pass to three different ASPX.net pages. Like this

<input id="txtAA" type="text" /><input id="btnAA" type="button" value="Sendto-AA" /><br />
<input id="txtBB" type="text" /><input id="btnBB" type="button" value="Sendto-BB" /><br />
<input id="txtCC" type="text" /><input id="btnCC" type="button" value="Sendto-CC" /><br />

When btnAA is clicked, it takes whatever value was entered in txtAA and passes it, on the query line, to http://mysite.com/AA.aspx
When btnBB is clicked, it takes whatever value was entered in txtBB and passes it, on the query line, to http://mysite.com/BB.aspx
When btnCC is clicked, it takes whatever value was entered in txtCC and passes it, on the query line, to http://mysite.com/CC.aspx

Can anyone help?
0
Comment
Question by:volking
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 11

Expert Comment

by:cmhunty
ID: 20385623
Why does it have to be a button? Can you not use a normal hyperlink? When the textbox changes, you can fire a javascript function which appends the query string to the end of the URL in the link?
0
 
LVL 5

Author Comment

by:volking
ID: 20385660
Isn't a button the standard way to let a user know the field you just typed will be used by the button.

Where a hyperlink doesn't LOOK like it's submitting anything.

I guess I could put an href wrapped around a "picture-of-a-button", will that work?
0
 
LVL 5

Author Comment

by:volking
ID: 20385672
Can a javascript be executed on a button click? How?
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 12

Expert Comment

by:Rok-Kralj
ID: 20385732
<input id="txtAA" type="text" /><input id="btnAA" type="button" value="Sendto-AA" onclick="document.location='http://mysite.com/AA.aspx'" /><br />
0
 
LVL 12

Expert Comment

by:Rok-Kralj
ID: 20385740
sorry:

<input id="txtAA" type="text" /><input id="btnAA" type="button" value="Sendto-AA" onclick="document.location='http://mysite.com/AA.aspx?id='+document.getElementById('txtAA');" /><br />
0
 
LVL 13

Accepted Solution

by:
R7AF earned 500 total points
ID: 20385771
I would create three separate forms, using normal submit buttons. No javascript required, works in all browsers.
<form action="http://mysite.com/AA.aspx" method="get">
<input id="txtAA" type="text" />
<input id="btnAA" type="submit" value="Sendto-AA" />
</form>
 
<form action="http://mysite.com/BB.aspx" method="get">
<input id="txtBB" type="text" />
<input id="btnBB" type="submit" value="Sendto-BB" />
</form>
 
<form action="http://mysite.com/CC.aspx" method="get">
<input id="txtCC" type="text" />
<input id="btnCC" type="submit" value="Sendto-CC" />
</form>

Open in new window

0
 
LVL 13

Expert Comment

by:R7AF
ID: 20385808
To clarify myself, these three forms are on the same page. And the forms need a name!
<form name="BB" action="http://mysite.com/BB.aspx" method="get">

Open in new window

0
 
LVL 5

Author Comment

by:volking
ID: 20395655
@R7AF - Excellent! And three separate form submissions means each form will URLencode the texbox values automatically, right?
0
 
LVL 13

Expert Comment

by:R7AF
ID: 20395776
Yes! Try and see it yourself.
0
 
LVL 5

Author Closing Comment

by:volking
ID: 31412042
Thanks! It works!
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question