-3

I want to set the value on an input element like this:

<input type="submit" name="submit" id="loginButton" value="<script>document.write(language['login'])</script>"/>

but i can't get it to work. Is it not possible?

Ingrid trav
  • 35
  • 1
  • 5
  • Sure it is possible, but not _that_ way. The `value` is pure text, you can not put script code in there and expect that to get executed. – CBroe Jul 27 '17 at 08:48
  • Set this value by getting element through document.getElementById in javascript – Amit Kumar Singh Jul 27 '17 at 08:48
  • Ok, of course i knew about these different approaches but was just wondering. I was thinking of some kind of escape that would make it possible but it can't be done like that. Thanks for answering. – Ingrid trav Jul 27 '17 at 08:54

1 Answers1

0

With Javascript, you can attribute a value to the property value by using setAttribute function.

Here is a possible solution :

var button = document.getElementById("#loginButton"); //Select your button element
button.setAttribute("value","Your value to set"); //Set value attribute to your element

Good luck !

Arrabidas92
  • 1,113
  • 1
  • 9
  • 20