SuperString
SuperString

Reputation: 22519

html submit links

I want to create a submit link instead of a submit button.

It looks like any ordinary link (blue and underlined) and when you click on it, the form is submitted.

Edit: is it possible to do this without javascript/jquery?

Upvotes: 4

Views: 13268

Answers (6)

Jack Billy
Jack Billy

Reputation: 7211

You can achieve this simply by using jquery!

Just do the following code ---

$('.your-sumbmit-link').click(function (e) {
   e.preventDefault();
   $('.your-form').submit();
});

Hope this helps!

Upvotes: -1

Howard
Howard

Reputation: 3848

No js, only CSS

<input type="submit" value="ABC" style="background:none; border-width:0px; color:blue; text-decoration:underline;" />

Upvotes: 5

Tom Gullen
Tom Gullen

Reputation: 61737

You can do it with Javascript:

<a href="#" onclick="document.formName.submit();return false;">submit form</a>

Edit:

This page:

http://www.beginningjavascript.com/Chapter4/exampleSubmitToLinks.html

has styled a button to look like a link, but it still uses Javascript to achieve it.

Upvotes: 3

Shaz
Shaz

Reputation: 15867

Sure!

HTML:

<form>
    <input type="text" placeholder="name" />
    <button type="submit">Submit</button>
</form>

CSS:

button {
    background: none;
    border: none;
    color: blue; text-decoration: underline;
    cursor: pointer;
}

Example here: http://fiddle.jshell.net/Shaz/AQDcD/1/

Upvotes: 1

Nick Pyett
Nick Pyett

Reputation: 3408

You can style the button to look like a link. i.e.

<input type="submit" value="submit" style="cursor: pointer; background-color: transparent; text-decoration: underline; border: 0; color: blue;" />

I'd do it with a stylesheet, rather than the inline styles, but you get the picture.

Upvotes: 0

user527892
user527892

Reputation:

jQuery can do this easily enough:

See: http://api.jquery.com/submit/

$('.submit-link').click(function(){
  $('#form-id').submit();
});

Upvotes: 0

Related Questions