Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML Input is not updating value attribute on change

Tags:

html

forms

OOPS, Since the "name" field was at the top it was the one I was testing with, and it turned out that was the only one with an issue. Must have something to do with using "name" as the name...


For some reason the input tags in my form are not updating the value attribute when they are changed view the actual element (not JavaScript). The data posted to the server is the original value of the "value" attribute, not the text in the textbox.

The textareas in the form work fine, and I have checked javascript fired "onchange" and I can't find any... Help please!

Here is the HTML:

<form action="" method="post">
<div id="group-1" class="group case">
  <a class="heading open">heading</a>
  <input name="editform[0][class]" value="case" type="hidden">
  <input name="editform[0][id]" value="2" type="hidden">
  <div class="field">
    <label>Name</label>
    <input class="text" name="editform[0][name]" value="Mike Escarcaga" type="text" >
  </div>
  <div class="field">
    <label>Title</label>
    <input class="text" name="editform[0][title]" value="General Manager" type="text" >
  </div>
  <!-- repeated for each field -->
  <div class="field" >
    <label >Text</label>
    <textarea class="ltext" name="editform[0][text]" >
      Blah HTML, and more blah...
    </textarea>
  </div>
</div>
<!-- repeated for each group in the form (editform[1], editform[2], etc.) -->
</form>
like image 443
Spencer Alger Avatar asked Nov 02 '11 19:11

Spencer Alger


2 Answers

The value attribute contains the default value for an input, not the live value.

The DOM value property contains a live value.

like image 90
Quentin Avatar answered Sep 18 '22 15:09

Quentin


Agree With @Quentin Dom Contain Live Value and HMTL Input contain Default Value for an input So for Changing the Default Value of the input use This Javascript Trick

document.getElementById("myText").defaultValue = "Goofy";
like image 27
Mr Talha Avatar answered Sep 17 '22 15:09

Mr Talha