Welcome to WebmasterWorld Guest from 3.209.80.87

Forum Moderators: open

Message Too Old, No Replies

text link to submit form

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

Full Member

10+ Year Member

joined:Apr 27, 2003
posts:243
votes: 0


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
6:54 am on Dec 8, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Jan 21, 2002
posts:977
votes: 0


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.

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

Full Member

10+ Year Member

joined:Apr 27, 2003
posts:243
votes: 0


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?
9:38 pm on Dec 8, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Jan 21, 2002
posts:977
votes: 0


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

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

Senior Member

WebmasterWorld Senior Member drdoc is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 15, 2002
posts:6807
votes: 0


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

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

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

Full Member

10+ Year Member

joined:Apr 27, 2003
posts:243
votes: 0


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?

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

Senior Member

WebmasterWorld Senior Member drdoc is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 15, 2002
posts:6807
votes: 0


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.