javascript - 表单提交按钮值

标签 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,那么我会得到所有提交按钮的值

最佳答案

在您的代码中调用

document.myform.submit();

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

关于javascript - 表单提交按钮值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29123989/

相关文章:

javascript - 为什么 CVE-2021-33623 容易受到 ReDoS 攻击?

javascript - 等待循环与 Promise.all

javascript - 如何在jquery中选择ul的li元素?

php - Laravel:我如何从这个数据透视表中获取数据?

php - 如何在 Laravel 5.2 中编写这个查询?

javascript - Angular POST 请求未执行

javascript - 找到 Mongoose 文档,然后按不同层进行随机排序?

php - 函数中的 CodeIgniter "Using $this when not in object context"

php - 存储数据的奇怪字符编码,旧脚本显示它们很好,新脚本却没有

php - 如何处理字符粘在一起的长字符串