Note that there are some explanatory texts on larger screens.

plurals
  1. POButton text different than value submitted in query string
    primarykey
    data
    text
    <p><b>Short version:</b> </p> <p>How can I have my form's button label text differ from the value submitted to the server <i>without</i> using the <code>&lt;button&gt;</code> tag?</p> <p><b>Long version:</b></p> <p>I wanted to have the text that appeared in a button in a form to be different than the value submitted in the query string. So, I looked around, and came across this approach...</p> <pre><code>&lt;button name="method" type="submit" value="repackage"&gt;Update Config&lt;/button&gt; </code></pre> <p>...and that worked on IE9 on one of my laptops and I was happy. The user saw "Update Config" and the server received <code>method=repackage</code> in the query string.</p> <p>Then I brought this app to work and ran it on a workstation, also with IE9. But something had gone wrong. The user still saw "Update Config", but the server now received <code>method=Update%20Config</code> in the query string.</p> <p>So I investigated some more. I found that www.w3schools.com recommmended not using a <code>&lt;button&gt;</code> tag in a form. They say: "If you use the <code>&lt;button&gt;</code> element in an HTML form, different browsers may submit different values. Use <code>&lt;input&gt;</code> to create buttons in an HTML form" in <a href="http://www.w3schools.com/tags/tag_button.asp" rel="nofollow noreferrer">this article</a>. This seems to be what I am experiencing.</p> <p>So I looked some more, and found lots of conflicting information about the right way to do this. For example <a href="https://stackoverflow.com/questions/5701831/input-type-button-label-vs-value">here is a Stack Overflow post</a> that asks exactly this question, but the accepted answer is to use the <code>&lt;button&gt;</code> tag. I can say from experience and research that this is not a reliable approach.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload