1

I would like to change the displayed text of an input submit button from say foo, to bar. BUT I don't want to change the value. Can anyone help?

<input type="submit" name="random" value="foo" />
Explosion Pills
  • 188,624
  • 52
  • 326
  • 405
Zachrip
  • 3,242
  • 1
  • 17
  • 32
  • 1
    Is there a reason to this madness? Maybe we can help you find a better solution to whatever you are trying to work around. – donutdan4114 Sep 18 '12 at 23:27

3 Answers3

2

Sorry, but you can't. You can try this, though:

<button value="foo">bar</button>
Explosion Pills
  • 188,624
  • 52
  • 326
  • 405
0

copy paste production:

< script type="text/javascript" >
function replaceScript() {
    var toReplace = 'value="foo"';
    var replaceWith ='value="bar"';
    document.body.innerHTML = document.body.innerHTML.replace(toReplace, replaceWith);
}
< /script >

Then initialise in the body tag to do on page load.

<body OnLoad = "replaceScript();">

Should work fine and replace all instances in html body code.

source: find and replace string

Community
  • 1
  • 1
rahim701
  • 51
  • 1
  • 8
  • This would work except there is hundreds of instances of the input buttons all with different values, I got what I needed though, and it's better than what I had planned in this question. Thanks anyways though! – Zachrip Sep 20 '12 at 03:10
  • Can you share what you got please? – Ege Bayrak Mar 09 '16 at 08:36
-1

<button type="submit" name="random" value="foo">bar</button> This work for me. Tested on Chrome and Firefox.

Sachintha
  • 509
  • 4
  • 14