Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Using the anchor tag to submit a form

Posted on 2000-02-19
8
Medium Priority
?
480 Views
Last Modified: 2010-04-09
Is there a way to submit a form using the <A> tag?  
0
Comment
Question by:pnod
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 2

Expert Comment

by:johnny99
ID: 2539000
No.

There's a way to submit form *data*, but not the data filled out by someone, only form data pre-coded into the page.

You can submit a form with an image, which you can fake up to look like text, of course.

0
 
LVL 6

Expert Comment

by:tecbuilder
ID: 2539156
What did you want to occur when you submit the form, e.g. send the contents of the form via email from a cgi or perl script, or mailto, just do something on the client (user's browser only), etc.

tec
0
 

Author Comment

by:pnod
ID: 2539246
I'd like to capture the contents of a textfield in a session variable for use later on.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 6

Accepted Solution

by:
tecbuilder earned 800 total points
ID: 2539285
Then the answer is yes.  You would use something like code below.  I set a couple of variables just to show something being done.  However, you would change function doSomething() to actually save the values of the form's contents, i.e. cookies or variables used within a frameset.

<script language="JavaScript">
<!--
var yourVariable1="";
var yourVariable2="";

function doSomethin() {
  yourVariable1 = document.myform.field1.value;
  yourVariable2 = document.myform.field2.value;
}
//-->
</script>

A form would then look something like the following.  The anchor tag can be inside or outside of the form tag.  It doesn't matter.

<form name="myform">

<!-- your form's contents goes in here -->

<a href="javascript:void(0)" onClick="doSomething()">Click Me</a>
</form>

tec
0
 
LVL 6

Expert Comment

by:tecbuilder
ID: 2539288
In addition, you can also use the following code to actually submit the form.  I just realized that this might be more specific to your question.

<script language="javascript">
<!--
function SubmitMe() {
  document.myform.submit();
}
//-->
</script>


The anchor tag would then look like:

<a href="javascript:void(0)" onClick="SubmitMe()">Click Me</a>

tec
0
 
LVL 6

Expert Comment

by:tecbuilder
ID: 2539319
I just realized an even simpler way to write the submit via a link, which would be what I would suggest using.  This way you don't need an extraneous code.

<A HREF="javascript:void(0)" onClick="document.myform.submit(); return false">

tec
0
 

Expert Comment

by:xyzffff
ID: 2539429
<script language=javascript>
letsubmit()
{
   form1.submit
}
</script>

<form name="form1" method="POST" action="action.asp">
.......
</form>
<a href="javascript:letsubmit()">submit</a>
0
 

Author Comment

by:pnod
ID: 2539474
Thanks for the help.  I really appreciate it.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

610 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