-3

I have a little problem by writing some text into this input-field.

<input type="text" data-pseudo-text="true" data-selector=".attribute-orderfield1--hidden" placeholder="some text" name="attribute_orderfield1_value" id="attribute_orderfield1_value" class="input--attribute-orderfield1" data-type-aof="input">

I tried it before in a test without the attribute data-type-aof and it worked.

document.getElementById("attribute_orderfield1_value").innerHTML = "some text";

Is this attribute preventing writing into the field via JS?

El Dan
  • 3
  • 1
  • 1
    It's .value not .innerHTML – Lain Dec 12 '16 at 08:58
  • Thanks to everyone. Unfortunately it doesn't do the trick here. It is in a Plugin, where i try to change the value in the input. I thought to might get around diving into the code of it, but there is a bunch of other JS in the Plugin which prevents writing/or overwrites it right after changing the value. Thanks again for the great and quick answers! – El Dan Dec 12 '16 at 09:32

4 Answers4

1

If I understand you correctly, you are just trying to set the value, just use:

document.getElementById("attribute_orderfield1_value").value = "some text";
Dr. Roggia
  • 1,095
  • 3
  • 16
  • 40
1

innerHTML is used to add html elements to respective DOM elements. For input elements use value instead.

document.getElementById("attribute_orderfield1_value").value = "NEW Text";
<input type="text" data-pseudo-text="true" data-selector=".attribute-orderfield1--hidden" placeholder="some text" name="attribute_orderfield1_value" id="attribute_orderfield1_value" class="input--attribute-orderfield1" data-type-aof="input">
Smit
  • 395
  • 3
  • 12
0
document.getElementById("attribute_orderfield1_value").value = "some text";

Try It InnerHTML not Equal to value

Samudrala Ramu
  • 2,088
  • 1
  • 15
  • 36
0

With input fields you're not supposed to use innerHTML to change the text inside. Technically what you're trying to change is the [value] attribute of the input field.

Try the following JS

document.getElementById("attribute_orderfield1_value").value = "New Text In Input Field";
Newbie
  • 386
  • 4
  • 19