表单提交按钮值

时间:2015-03-18 13:54:25

标签: javascript php

<form action="mail.php" method="post" id="myform" name="myform" onsubmit="javascript:return validForm(document.myform)">
  <input type="submit" class=" " name='btnanother' id='btnanother' value='asdf'>
  <input type="text" class="txtinput" name="fname" id="fname" value="First &amp; Last Name" onblur="if(this.value==''){this.value='First &amp; Last Name'}" onfocus="if(this.value=='First &amp; Last Name'){this.value=''}">

  <input type="text" class="txtinput" name="phone" id="phone" value="Phone" onblur="if(this.value==''){this.value='Phone'}" onfocus="if(this.value=='Phone'){this.value=''}">

  <input type="text" class="txtinput" name="email" id="email" value="Email Address" onblur="if(this.value==''){this.value='Email Address'}" onfocus="if(this.value=='Email Address'){this.value=''}">

  <input type="text" class="txtinput" name="location" id="location" value="Location" onblur="if(this.value==''){this.value='Location'}" onfocus="if(this.value=='Location'){this.value=''}">

  <input type="text" class="txtinput" name="sqrfoot" id="sqrfoot" value="Square Foot of Basement" onblur="if(this.value==''){this.value='Square Foot of Basement'}" onfocus="if(this.value=='Square Foot of Basement'){this.value=''}">

  <textarea name="describe" class="txtarea" id="describe" onblur="if(this.value==''){this.value='Describe your basement project'}" onfocus="if(this.value=='Describe your basement project'){this.value=''}">Describe your basement project</textarea>

  <div class="banner_captcha">
    <div class="banner_captcha_img">
      <img src="captcha_code_file.php?rand=<?php echo rand(); ?>" id='captchaimg'>
    </div>
    <div class="banner_captcha_txt">
      <label for='message'>Enter the code here :</label>
      <br>
      <input id="letters_code" name="letters_code" type="text" value="">
    </div>
  </div>
  <br>
  <small>Can't read the image? click <a href='javascript: refreshCaptcha();'>here</a> to refresh</small>

  <div class="align-center">
    <input type="submit" class=" " name='btnanother' value='submit' style="text-indent:0px;" />
    <input type="submit" class=" " name='asfdas' value="asdfasdf" style="text-indent:0px;" />
    <input type="submit" class="submit" name='btnSubmit' value="asdf" style="text-indent:0px;" />

  </div>

在mail.php上没有获取提交按钮值。

如果我禁用了javascript,那么我将获得所有提交按钮值

1 个答案:

答案 0 :(得分:0)

在你的代码中你打电话

document.myform.submit();

当您以这种方式触发表单提交时,您不会收到提交按钮。