Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/455.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/242.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用提交按钮清除输入_Javascript_Php_Html - Fatal编程技术网

Javascript 使用提交按钮清除输入

Javascript 使用提交按钮清除输入,javascript,php,html,Javascript,Php,Html,从C语言切换到PHP语言一段时间,却看不出我做错了什么 我想做的是,当我点击提交按钮时——我希望电子邮件像现在一样发送,但我希望输入文本字段清除用户以前输入的旧文本 我找到的一种方法是在提交之前清除测试,这对我没有多大帮助 关于如何做到这一点有什么意见吗 <?php /* * Template Name: Contact * Description: Contact Us */ get_header(); ?> <div class="container"&g

从C语言切换到PHP语言一段时间,却看不出我做错了什么

我想做的是,当我点击提交按钮时——我希望电子邮件像现在一样发送,但我希望输入文本字段清除用户以前输入的旧文本

我找到的一种方法是在提交之前清除测试,这对我没有多大帮助

关于如何做到这一点有什么意见吗

<?php
/*
 * Template Name: Contact
 * Description: Contact Us
  */
 get_header();
  ?>

 <div class="container">
 <div class="section group">
<div class="col span_2_of_2">
<h1> Contact Us <h1>
 <p style="font-size:16px"> Radiology Services LLC is located on the east side of   Evansville, IN off the Robert D. Orr Highway.</p>
<iframe src="https://www.google.com/maps/embed?pb=!1m14!1m8!1m3!1d3146.027108890167!2d-   87.45272299999999!3d37.953153!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x0%3A0x170f5925d75e6135!2s    Radiology+Services+LLC!5e0!3m2!1sen!2sus!4v1404175203674" width="100%" height="350px"    frameborder="0" style="border:0"></iframe>
</div>
<div class="col span_1_of_2" style="padding-left:40px;>
<?php

//response generation function

 $response = "";

 //function to generate response
 function my_contact_form_generate_response($type, $message){

 global $response;

 if($type == "success") $response = "<div class='success'>{$message}</div>";
 else $response = "<div class='error'>{$message}</div>";

 }

//response messages
$not_human       = "Human verification incorrect.";
$missing_content = "Please supply all information.";
$email_invalid   = "Email Address Invalid.";
$message_unsent  = "Message was not sent. Try Again.";
$message_sent    = "Thanks! Your message has been sent.";

 //user posted variables
 $name = $_POST['message_name'];
 $email = $_POST['message_email'];
 $message = $_POST['message_text'];
 $human = $_POST['message_human'];

 //php mailer variables
 $to = 'aje@gmail.com';
  $subject = "Someone sent a message from ".get_bloginfo('name');
   $headers = 'From: '. $email . "\r\n" .
 'Reply-To: ' . $email . "\r\n";

 if(!$human == 0){
   if($human != 2) my_contact_form_generate_response("error", $not_human); //not human!
   else {

  //validate email
  if(!filter_var($email, FILTER_VALIDATE_EMAIL))
    my_contact_form_generate_response("error", $email_invalid);
  else //email is valid
  {
    //validate presence of name and message
    if(empty($name) || empty($message)){
      my_contact_form_generate_response("error", $missing_content);
    }
    else //ready to go!
    {
      $sent = wp_mail($to, $subject, strip_tags($message), $headers);
      if($sent) my_contact_form_generate_response("success", $message_sent);
      else my_contact_form_generate_response("error", $message_unsent); 
    }
  }
}
}
  else if ($_POST['submitted']) my_contact_form_generate_response("error",    $missing_content);
?>
  <?php while ( have_posts() ) : the_post(); ?>
        <div class="entry-content">
          <?php the_content(); ?>



 <style type="text/css">
            .error{
              padding: 5px 9px;
              border: 1px solid red;
              color: red;
              border-radius: 3px;
            }

            .success{
              padding: 5px 9px;
              border: 1px solid green;
              color: green;
              border-radius: 3px;
            }

            form span{
              color: red;
            }

 .subBtn{
 width:100%;
  border-radius: 0px;
 background-color:#5bb75b;
 color:#FFFFFF;
  }
  .subBtn:hover{
  background-color:#408140;
  }
  .m{
 width:100%;
  border-radius: 0px;
 }
          </style> 
  <script language="javascript">
  fromreset()
  {
  myform.reset(); 

 document.myform.[textbox Id] = " "; 
 }
</script>


<form name="myform" id="myform"action="<?php the_permalink(); ?>" method="post">
<label for="name" class="m">Name: <span>*</span> <br>
<input type="text" class="m" id="name" name="message_name" value="<?php echo esc_attr($_POST['message_name']); ?>">
</label>
<label for="message_email" class="m">Email: <span>*</span> <br>
<input type="text" class="m" id="email" name="message_email" value="<?php echo esc_attr($_POST['message_email']); ?>">
</label>    
<label for="message_text" class="m" id="mu">Message: <span>*</span> <br>
<textarea type="text" class="m" id="textm" name="message_text"><?php echo     esc_textarea($_POST['message_text']); ?></textarea>
</label>
<label for="message_human" class="m">Human Verification: <span>*</span> <br>
 <input type="text" class="m" name="message_human"> + 3 = 5
</label>
<input type="hidden" name="submitted" value="1"  class="m">
<input type="hidden" name="submitted" value="1" style="width:100%">
<input type="submit" value="submit" class="subBtn" onclick="formreset();">

 <?php echo $response; ?>
 </form>           
</div>
</div>
  <?php endwhile; // end of the loop. ?>

</div><!-- #content -->

为什么要在提交前清空字段?你想发布一张空表单吗?可能是document.myform[textbox Id]=;请澄清您的问题@AndrewRemove onclick函数,您的fromreset it是无效的JavaScript,可能正在生成错误并没有正确提交。提交表单时,只要表单上有action属性,字段就会自动重置,因为它会加载新页面。
</div>
<?php get_footer(); ?>