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" />
1
  • 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. Commented Sep 18, 2012 at 23:27

3 Answers 3

3

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

<button value="foo">bar</button>
Sign up to request clarification or add additional context in comments.

4 Comments

ie < 9 will submit bar if this button is within the form
No thanks D: I want to keep the code I have and add code. (that's just my standpoint for this, not other issues I may have.)
@user1420493 then you can't do it with <input>. Sorry!
It's okay, I just found a different way to do it with css :)
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

2 Comments

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!
Can you share what you got please?
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.