Forum Moderators: open

Message Too Old, No Replies

text link to submit form

         

bobnew32

4:37 am on Dec 8, 2003 (gmt 0)

10+ Year Member



Now, I have a form setup on a page, but instead of conventional buttons, I want a text url to launch the form with the selected url. Since I have various submit buttons, meaning more urls, it also has to be able to submit the right submit button. Thx for all the help

Purple Martin

6:54 am on Dec 8, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm not sure what you mean by "text url". I'll assume that you mean text links (using <a> tags).

You can add a bit of JavaScript to the link that will submit a specific form. One way to do it would look like this:

<a href="javascript:document.forms[0].submit()">Submit the first form</a>

Note that the [0] is for the first form on the page. Use [1] for the second form, [2] for the third form, and so on.

bobnew32

9:10 pm on Dec 8, 2003 (gmt 0)

10+ Year Member



Yes but which submit button would be getting hit with that, the one just called submit? And where is the value of submit getting set?

Purple Martin

9:38 pm on Dec 8, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes but which submit button would be getting hit with that, the one just called submit?

The JavaScript submit() method submits the specified form (the form specified by the number in the square brackets). In other words, it does the same thing as clicking on that form's submit button.

And where is the value of submit getting set?

I think you're talking about the value attribute of the input tag:
<input type="submit" value="Submit">

The value attribute specifies what words appear on the button. For our text link, the equivalent thing is just the text of the link.

You need to learn the basics of the common HTML tags. You'll find a comprehensive reference that explains all the tags and their attributes here:
[w3schools.com...]

HTH

DrDoc

9:45 pm on Dec 8, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can also just use this.form.submit() thus:

<a href="javascript:this.form.submit()">Submit this form</a>

bobnew32

2:42 am on Dec 9, 2003 (gmt 0)

10+ Year Member



Actually, i'm fully versed in html and php which i'm trying to put an array of checkboxes into :)

I have one form, with multiple submit buttons.

<input type=submit name=function value="Move Selected">
<input type=submit name=function value="Close Selected">
<input type=submit name=function value="Open selected">
<input type=submit name=function value="Float Selected">

Multiple submit buttons, per say how would I link to.... Close Selected getting hit?

DrDoc

5:44 am on Dec 9, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'd stick with regular submit buttons. There are ways you can handle it in JavaScript, but there's always the big "if" related to poor browser support and users turning JavaScript off.