wrussell051197
asked on
POSTing without a button
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?
<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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try
<A HREF="JavaScript:document. forms[0].s ubmit("But ton1")">cl ick here to submit</A>
and
<A HREF="JavaScript:document. forms[0].s ubmit("But ton2")">cl ick here to submit</A>
Haven't tried it out yet, myself, but it seems like it should work.
<A HREF="JavaScript:document.
and
<A HREF="JavaScript:document.
Haven't tried it out yet, myself, but it seems like it should work.
Ooops! That should be
<A HREF="JavaScript:document. forms[0].s ubmit('But ton1')">cl ick here to submit</A>
and
<A HREF="JavaScript:document. forms[0].s ubmit('But ton2')">cl ick here to submit</A>
(Used the wrong quotes the first time).
<A HREF="JavaScript:document.
and
<A HREF="JavaScript:document.
(Used the wrong quotes the first time).
another possible way:
<SCRIPT LANGUAGE="JavaScript"><!--
function submit1(){
document.forms[0].hide.val ue="button 1";
document.forms[0].submit()
}
function submit2(){
document.forms[0].hide.val ue="button 2";
document.forms[0].submit()
}
(this goes to your <HEAD> part of the page)
and add this to your form:
<INPUT TYPE="HIDDEN" NAME="hide">
<SCRIPT LANGUAGE="JavaScript"><!--
function submit1(){
document.forms[0].hide.val
document.forms[0].submit()
}
function submit2(){
document.forms[0].hide.val
document.forms[0].submit()
}
(this goes to your <HEAD> part of the page)
and add this to your form:
<INPUT TYPE="HIDDEN" NAME="hide">
ASKER
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.val ue = 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?
<A HREF="JavaScript:submit1()
???
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.val
document.forms[0].submit()
}
<Input type=hidden name=hide>
<A HREF = "JavaScript:submitinfo(104
<A HREF = "JavaScript:submitinfo(105
something like that?
ASKER
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.val ue = 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?
<A HREF="JavaScript:submit1()
???
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.val
document.forms[0].submit()
}
<Input type=hidden name=hide>
<A HREF = "JavaScript:submitinfo(104
<A HREF = "JavaScript:submitinfo(105
something like that?
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('10 4')">
instead
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('10
instead
ASKER
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.
Go ahead and give them to Christian....
ASKER
Ok, thanks for all the help, both of you :)
ASKER
<input type=submit name="cmdbutton1" value=button1>