Submit a form using <a> anchor element, without javascript - html

How to replace the submit button with a link without using javascript ? is there any way to add the submit attribute to a link ? because the form will not be sent by a simple link without "submit".
<form:form action="/getPage" >
<div class="buttons">
<a class="link" href="">
<img src="icon.png" />
</a>
</div>
</form:form>
I work in an application web so if i use javascript the link will not be mapped by the server ..

You can not submit a form using an <a> tag alone. You will need some type of javascript to assist, if you insist on using the <a> tag:
Submit the Form
or
Submit the Form
or super hack:
Submit the Form, then on backendPage.php you can use $_GET requests to process information, and redirect the visitor to the intended page. But that's a horrible idea haha

Try this:
CSS
button {
background:none!important;
border:none;
padding:0!important;
/*border is optional*/
border-bottom:1px solid #444;
}
HTML
<button>your button that looks like a link</button>

This can achieve the same effort and it looks like <a>
Note: btn btn-link comes from bootstrap
<button class="btn btn-link" type="submit"><img src="icon.png" /></button>

There is an another way out. Using this method you can use any element to submit a form.
Following is an example:
<span onclick="$('#submit').trigger('click')" style="cursor:pointer;">
anything
</span>
Add a hidden submit button:
<input style="display:none;" type="submit" id="submit"/>
This will behave exactly as actual submit button.

Related

How to submit a form with JavaScript by clicking a class font awesome link?

Instead of a submit button I have a link:
<form action="{{ route('schools-list.destroy', ['id' => $school_list->id]) }}">
{{ method_field('DELETE') }}
<a onclick="document.form.submit"><span class="glyphicon glyphicon-remove"></span></a>
</form>
Can I make it submit the form when it is clicked?
the easiest way would be to create a tag for the fontawesome icon and then wrap that in a tag. Like this:
<button> <i class="fontawesome class here"/></button>
To achieve what you are asking to do…
document.form.submit
You need to:
Replace document.form with something that actually gets a reference to the form such as document.the_id_of_the_form (although document.getElementById("the_id_of_the_form") would be clearer).
Call the submit method instead of just mentioning it in passing (i.e. submit()).
However.
Links are supposed to link to places.
Forms are supposed to be submitted with submit buttons.
Use a submit button.
You can put HTML inside it and style it to look however you like:
<button><span class="glyphicon glyphicon-remove"></span></button>
… this will (a) not depend on JavaScript and (b) be announced as a submit button by screen readers.
You can use a class and add onclick event to it and then submit the form

Button with url

I wanna switch this code:
Inapoi
With a button. I want a button who redirect to ”selectare_gen.php”
I tried:
<button onclick="location.href='selectare_gen.php'">Inapoi</button>
But all it does is refreshing the current page..
It should be
<button type="reset" onclick="location.href='selectare_gen.php'">
Inapoi
</button>
The type="reset" is a workaround to prevent the browser from interpreting the button as a form element which causes the reload.
Check this link over here. It should answer your question.
How to create an HTML button that acts like a link?
Many browsers think that the <button> tag will cause a submit that's why it's appearing to just refresh the page. If you use an input type="button" it wouldn't have this effect:
<input type="button" onclick="window.location='selectare_gen.php';" value="Inapoi" />

Put HTML into submit button's value

I have a submit button that is used to save a form. Inside the submit button I want to use a HTML tag. I am using Font Awesome and I would like the save icon to appear next to the word save in the button. The HTML for this is
<i class="icon-save"></i> Save
The only problem is I cannot seem to get HTML to render inside the value="" property on the submit button. How can I get HTML to render inside the submit button? This doesn't parse the HTML, it actually renders a button with the literal contents
<input type="submit" value="<i class='icon-save'></i> Save" />
Here is an example of what I want
did you try the button tag like this :
<button type="submit">
<i class='icon-save'></i> Save
</button>
Using background image can also achieve this JSFiddle
<input type="button"
style="background-image:url(http://icons.iconarchive.com/icons/double-j-design/ravenna-3d/24/Access-icon.png);
background-position:left; background-repeat:no-repeat;
padding-left:30px; padding-top:4px; padding-bottom:4px; padding-right:4px"
value="Save" />​

Creating a input link button

hello all a quick question..
i am building a static html page, and would like to like one page to another using a button, now using a link is the easier option but i would like the effect of a button without any javascript going off..
so i would like to use a input button but it to link to a html page like an tag can href.
i was thinking along the lines of this example but without the js..
<form>
<input type="button" value="Read more" class="button" onclick="window.location.href='testimonials.html'">
</form>
this doesnt work but i am looking for this functionality?? is it possible?
Just submit the form to the URL.
<form action="testimonials.html">
<input type="submit" value="Read more">
</form>
… but buttons are supposed to do stuff. Links go places. Don't send people mixed messages, use a link.
you've misspelled "onclick" :)
EDIT: if you want to avoid javascript, you can create a button-like link with CSS:
Read More
Try this code:
<form>
<input type="button" value="Read more" class="button" onlick="window.location='testimonials.html'">
</form>

button tag submitting

i am using this plain html code inside an aspx page. it renders well, but when clicked it submits / reloads the page. i dont want anything to be done on click of this button. whats d issue
<button>
btn1</button>
<button>
btn2</button>
It'll default to type=submit if no type is explicitly given.
You want to put
<button type="button">btn1</button>
Not sure if by pure html you can do so however this way you can black the default submit behaviour:
<button id="a" onclick="return false;">button</button>
Don't use <button>. Use <input> instead:
<input type="button" id="btn1" />
Also, worth noting (from http://www.w3schools.com/tags/tag_button.asp):
If you use the button element in an
HTML form, different browsers will
submit different values. Internet
Explorer will submit the text between
the <button> and </button> tags, while
other browsers will submit the content
of the value attribute. Use the input
element to create buttons in an HTML
form.