html - Cross-browser and JavaScript-less solution to submit button value issue -
given following 2 buttons:
<button type="submit" name="mybutton" value="foo">do foo</button> <button type="submit" name="mybutton" value="bar">do bar</button>
when clicking these buttons, browsers except ie7 , below post button's value ("foo" or "bar"), whereas ie7 , below instead post text ("do foo" or "do bar").
(this mvc project, issue not specific mvc.)
this thread has lot of answers, none of them work when:
- the value , text different, and
- javascript disabled
we want support flexible button text business can change these through our cms without code change. can't assume our text , values same. don't want depend on javascript solve this.
however, can't think of way solve without either requiring javascript, or keeping value , text same.
the usual hack key off name instead of value.
<button type="submit" name="mybutton_foo" value="foo">do foo</button> <button type="submit" name="mybutton_bar" value="bar">do bar</button>
then search submitted form values ones match pattern /^mybutton_(.*)$/
. there examples variety of languages (although not c#) in an article wrote years ago.
Comments
Post a Comment