Solved

POSTing without a button

Posted on 1998-06-14
11
249 Views
Last Modified: 2010-04-09
Is there any way to post form results without creating a button? Right now, what I have is something like this:

<FORM method=POST action=/cgi/mycgiprog.exe>
<input type=checkbox name=box1>
etc...
<input type=submit name=submit1 value=button1>
<input type=submit name=submit2 value=button2>
</FORM>

thats of course a very simplified version. The mycgiprogram called, takes action based on the value of the submit button pressed, each one calling a different section of the program. Now, my question is, can I create a submit "button" without creating an actual button? Basically, I want to make a plain text hotlink that will submit the form. Anyone know of any way this can be done?
0
Comment
Question by:wrussell051197
  • 5
  • 4
  • 2
11 Comments
 
LVL 5

Accepted Solution

by:
Christian_Wenz earned 100 total points
ID: 1844180
yeah: <A HREF="JavaScript:document.forms[0].submit()">click here to submit</A>

this won't work if the FORM's ACTION is set to mailto:xxx
0
 

Author Comment

by:wrussell051197
ID: 1844181
Ok, thats a start, but my program goes by the name of the submit button pressed to determine its action. Is there any way to associate a name as in:

<input type=submit name="cmdbutton1" value=button1>


0
 
LVL 3

Expert Comment

by:bigelos
ID: 1844182
Try
<A HREF="JavaScript:document.forms[0].submit("Button1")">click here to submit</A>

and

<A HREF="JavaScript:document.forms[0].submit("Button2")">click here to submit</A>

Haven't tried it out yet, myself, but it seems like it should work.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:bigelos
ID: 1844183
Ooops!  That should be

<A HREF="JavaScript:document.forms[0].submit('Button1')">click here to submit</A>

and

<A HREF="JavaScript:document.forms[0].submit('Button2')">click here to submit</A>

(Used the wrong quotes the first time).
0
 
LVL 5

Expert Comment

by:Christian_Wenz
ID: 1844184
another possible way:
<SCRIPT LANGUAGE="JavaScript"><!--
function submit1(){
 document.forms[0].hide.value="button1";
 document.forms[0].submit()
}
function submit2(){
 document.forms[0].hide.value="button2";
 document.forms[0].submit()
}

(this goes to your <HEAD> part of the page)


and add this to your form:

<INPUT TYPE="HIDDEN" NAME="hide">
0
 

Author Comment

by:wrussell051197
ID: 1844185
Ok, the example bigelos gave me submits ok, but still doesn't pass back a name/value pair. How would I use your example Christian?

<A HREF="JavaScript:submit1()">click here to submit</A>

???
never really used Java, so don't know that much about it. I could theoretically pass a parameter to this right? i.e.:
have no idea of the syntax for parameters, so I'm just going to guess:

function submitinfo(int mynum) {
  document.forms[0].hide.value = mynum;
  document.forms[0].submit()
}

<Input type=hidden name=hide>

<A HREF = "JavaScript:submitinfo(104)">click here to submit with a value of 104</A>
<A HREF = "JavaScript:submitinfo(105)">click here to sumit with a value of 105</A>

something like that?
0
 

Author Comment

by:wrussell051197
ID: 1844186
Ok, the example bigelos gave me submits ok, but still doesn't pass back a name/value pair. How would I use your example Christian?

<A HREF="JavaScript:submit1()">click here to submit</A>

???
never really used Java, so don't know that much about it. I could theoretically pass a parameter to this right? i.e.:
have no idea of the syntax for parameters, so I'm just going to guess:

function submitinfo(int mynum) {
  document.forms[0].hide.value = mynum;
  document.forms[0].submit()
}

<Input type=hidden name=hide>

<A HREF = "JavaScript:submitinfo(104)">click here to submit with a value of 104</A>
<A HREF = "JavaScript:submitinfo(105)">click here to sumit with a value of 105</A>

something like that?
0
 
LVL 3

Expert Comment

by:bigelos
ID: 1844187
Change the
function submitinfo(int mynum) {
to
function submitinfo(mynum) {

and it should work.

Just remember to put your JavaScript in between <script> and </script> containers.  In addition, you'll probably want it in the head section of your document.

Also, what you have might work, but it is more common to use single quotes when sending the value to the function.  I would use

<A HREF = "JavaScript:submitinfo('104')">

instead
0
 

Author Comment

by:wrussell051197
ID: 1844188
Ok, that worked. But since both of you helped me get the answer I needed, I'm not sure how to divide up points. I'll see if I can get the expert exchange people to split them for you.
0
 
LVL 3

Expert Comment

by:bigelos
ID: 1844189
Go ahead and give them to Christian....
0
 

Author Comment

by:wrussell051197
ID: 1844190
Ok, thanks for all the help, both of you :)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Someone recently asked me about how to display a progress indicator on a page while an iframe is loading. And I remember when I first came across this myself. It was a bit tricky to get my head around, but really, it's very simple. The most impor…
When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
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…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

713 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