Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change text from "Submit" on input tag

Tags:

html

I have a tag, <input type="submit" class="like"/>. I want to have the text inside the button say "Like", but right now, it says "Submit".

class="like" is the CSS of the button, by the way.

like image 436
user1261817 Avatar asked Dec 22 '12 23:12

user1261817


People also ask

How do I change input type submit value?

you want to change value after submit? The default behaviour of a form is to submit data, you need to tell it not to submit if you don't want it to. If you use event. preventDefault(); in the function triggered on submit this will remove the default behaviour of posting.

How do I change input type submit button name?

Input value attribute The value attribute can be used to change the text of the form submit button. Use value attribute within <input> of type="submit" to rename the button.

How do I turn off input submit?

Enable / Disable submit button 1.1 To disable a submit button, you just need to add a disabled attribute to the submit button. $("#btnSubmit"). attr("disabled", true); 1.2 To enable a disabled button, set the disabled attribute to false, or remove the disabled attribute.

Should I use input or button for Submit?

input suggests that the control is editable, or can be edited by the user; button is far more explicit in terms of the purpose it serves. Easier to style in CSS; as mentioned above, FIrefox and IE have quirks in which input[type="submit"] do not display correctly in some cases.


3 Answers

The value attribute on submit-type <input> elements controls the text displayed.

<input type="submit" class="like" value="Like" />
like image 124
Ry- Avatar answered Oct 08 '22 09:10

Ry-


The value attribute is used to determine the rendered label of a submit input.

<input type="submit" class="like" value="Like" />

Note that if the control is successful (this one won't be as it has no name) this will also be the submitted value for it.

To have a different submitted value and label you need to use a button element, in which the textNode inside the element determines the label. You can include other elements (including <img> here).

<button type="submit" class="like" name="foo" value="bar">Like</button>

Note that support for <button> is dodgy in older versions of Internet Explorer.

like image 33
Quentin Avatar answered Oct 08 '22 10:10

Quentin


<input name="submitBnt" type="submit" value="like"/>

name is useful when using $_POST in php and also in javascript as document.getElementByName('submitBnt'). Also you can use name as a CS selector like input[name="submitBnt"]; Hope this helps

like image 29
bashleigh Avatar answered Oct 08 '22 09:10

bashleigh