0

这是我通过单击文本提交的表单,但值未在操作页面上传递。

  <form action="forget_pass.php" method="post" id="new_user" name="new_user">
  <ul class="inputlist">
    <li><span class="redcolor">*</span>Email Address or Phone No.</li>
    <li>
      <input name="" class="inputbox" type="text" name="EmailAddress" id="txtEmail" />
      &nbsp;&nbsp;

      </li>

     <li class="rightalign">
     <a href="javascript:document.new_user.submit();" onclick="">
      Retrieve Password</a></li>

    </form>
4

3 回答 3

1
<input name="" class="inputbox" type="text" name="EmailAddress" id="txtEmail" />

应该

<input class="inputbox" type="text" name="EmailAddress" id="txtEmail" />

-

<a href="javascript:document.new_user.submit();" onclick="">

应该更好

<a href="#" onclick="document.new_user.submit();return false;">
于 2012-05-23T10:16:55.637 回答
1

这是您可以使用的工作代码

<form action="forget_pass.php" method="post" id="new_user" name="new_user">
  <ul class="inputlist">
    <li><span class="redcolor">*</span>Email Address or Phone No.</li>
    <li>
      <input class="inputbox" type="text" name="EmailAddress" id="txtEmail" />
      &nbsp;&nbsp;

      </li>

     <li class="rightalign">
     <a href="javascript:document.new_user.submit();">
      Retrieve Password</a></li>

    </form>

您的代码中的问题是

1-您有两个名称属性。一个是空的

2- onclick 没有正确使用...

希望能帮助到你

于 2012-05-23T10:22:47.380 回答
0

你应该试试这段代码,

<form action="forget_pass.php" method="post" id="new_user" name="new_user">
  <ul class="inputlist">
    <li><span class="redcolor">*</span>Email Address or Phone No.</li>
    <li>
      <input class="inputbox" type="text" name="emailAddress" id="txtEmail" >
      &nbsp;&nbsp;
      </li>
     <li class="rightalign">
     <a href="javascript:submitForm();">
      Retrieve Password</a></li>
    </ul>
</form>

而javascript代码是,

submitForm = function(){
    alert(document.forms[0].emailAddress.value);
document.forms[0].submit();
}

运行代码是这个http://jsfiddle.net/4AWW6/

于 2012-05-23T10:26:23.087 回答