Cannot post span value by document.form.submit

2019-02-28 16:34发布

问题:

I'm writing a form and use document.form.submit() to post value, and I hope I can use x = http.formvalue("") to get the value well. But I found if I submit <span> value then I'll get null, if I replace <span> to <input> then I can get the value well, can anyone help me get the value only use <span>? thx!

HTML

<form id="form1" name="form1" method="post">
  <ul class="formUl">
    <li>
      <span class="clm01">Phone:</span>
      <span class="clm02" id="phone" name="phone"></span>
    </li>
  </ul>
  <a class="submitBtn" href="#" onclick="apply()">Apply</a>
</form>

jQuery

function apply() {
    document.form1.submit();
}

回答1:

span is not a form element. Form elements are inputs, selects, radios, textareas, etc. That is why it works when you change it to an input.