HTML Submit-Button: Different Value/Button-Text

HTML Submit-button: Different value / button-text?

It's possible using the button element.

<button name="name" value="value" type="submit">Sök</button>

From the W3C page on button:

Buttons created with the BUTTON element function just like buttons created with the INPUT element, but they offer richer rendering possibilities: the BUTTON element may have content.

Submit buttons: button text different from value

You can use an hidden input to store the value count, it will be available after GET/POST:

<input type="submit" name="fields" value="add new field" />
<input type="hidden" name="fieldsCount" value="<?php echo $fields+1 ?>" />

Two submit buttons in one form

If you give each one a name, the clicked one will be sent through as any other input.

<input type="submit" name="button_1" value="Click me">

HTML Submit Button, different value to post data

Use a button element (which can have child nodes), not an input element (which cannot).

<button type="submit" value="name1" name="remove">Remove 1</button>

Note that old IE has limitations here.

Button text different than value submitted in query string

If there's no other way try this:

Use an image button, instead of button. An image button will work as ordinary submit button, but you create an image of the desired button text (no one can change your text then).

 <input type="image" src="http://images.webestools.com/buttons.php?frm=2&btn_type=31&txt=Update+Config" name="method" value="repackage">

Can I set two values for a submit button?

You can use data- attr

<button type="submit" name="buttonname" data-value="value2" value="Value1">value</button>

then use Element.getAttribute() live DEMO

var buttom = document.querySelector("button");
var dataValue = buttom.getAttribute("data-value");

alert(dataValue);

this way you can set as much value as you want just by add data-*

the best part is you can use

<input type="submit" name="buttonname" data-value3="value3" data-value="value2" value="Value1" />

Demo if you don't like button

Change text from Submit on input tag

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

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

Change display text from a html button from its value

Use a button element instead of an input element.

<button name="name" value="value submitted when clicked">Display Text</button>

Form with two button submit with different value

It seems that what you actually want to do is have a value in each of the buttons, see this, for example:

<form action="demo_form.asp" method="get">
Choose your favorite subject:
<button name="subject" type="submit" value="fav_HTML">HTML</button>
<button name="subject" type="submit" value="fav_CSS">CSS</button>
</form>


Related Topics



Leave a reply



Submit