Send Form Data to another Page via A <a href>

Dear all

I have a form which has got form controls on it mainly textboxes and combo boxes.

What I want to do is send the form data to another page via a link.

I know I can do this via a command button and setting the form action to get, however I have a update button on here which posts database back to a database.

Any ideas on how i can do this

Thanks in advance

Ajay
patelajkAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

babuno5Commented:
well u can make a <a href > with query string but with the previous form data and not with the current data in the form .
memerotCommented:
Javascript does it easily enough.  

Say you have this:
<input type="hidden" name="var1" id="var1" value="XYZ">
<input type="text" name="txtName" id="txtName" value="">   <-- user has now typed in 'Bob'

You want to have a link that passes info to another page, both the old stuff stored in hidden fields, and any info the user has typed into textboxes and the like.  Easiest is querystring, so that's first.

<script>
function passFormInfo() {
     var nextURL = "page2.asp?";
     nextURL += "var1=" + document.getElementById("var1").value;
     nextURL += "&txtName=" + document.getElementById("txtName").value;
     window.location.href=nextURL;
}
</script>

And the link looks like this:
<a href="javascript:passFormInfo()" title="Next Page">Next Page</a>

When you get there you have everything in the querystring though, which you might not want.  More complicated is to use an actual form post.  I won't show all the code.  If you wanted to do that, you'd make a second form after the end of your first form.  There are no submit buttons (or anything else user-actionable) in that form, so the user can't submit it - you have to do that for them in JavaScript.  In that form, put hidden form fields for all the hidden form fields in your first form, plus for all the text boxes and select lists.  The JavaScript function would change so that instead of concatenating a url string, for each form element you would set the corresponding hidden form field in your second form:

document.getElementById("form2_var1").value = document.getElementById("var1").value;

When they're all set you would submit the second form instead of the first form, so the end of your script is like this:

document.getElementById("form2").submit();
</script>

Kind of a pain, but it can be done.  Enjoy.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kiddangerCommented:
<form name="form1" method="get" action="nextpage.asp">
<input type="text" name="text1" value="text1" />
<select name="select1">
<option value="" selected></option>
<option value="select1">select1</option>
<option value="select2">select2</option>
</select>
</form>
<span onclick="document.form1.submit()">submit</span>
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.