Javascript 如何在数据库中插入datedropdown值

Javascript 如何在数据库中插入datedropdown值,javascript,php,html,Javascript,Php,Html,这是一些我需要你帮助的代码,在这段代码中,输入表单有一个名称,这样我就可以将输入表单的值存储到数据库中,并将其提取到另一个页面,但是那些带有脚本的文本字段无法识别,它称之为未定义变量,但如果文本字段本身没有脚本,它只需删除脚本即可工作。但我想通过脚本使用该插件n我想让你帮助我为什么无法识别名称变量wn我添加了该脚本它工作正常w/退出它 <?php $active = "";?> <?php include 'includes/header.php'; in

这是一些我需要你帮助的代码,在这段代码中,输入表单有一个名称,这样我就可以将输入表单的值存储到数据库中,并将其提取到另一个页面,但是那些带有脚本的文本字段无法识别,它称之为未定义变量,但如果文本字段本身没有脚本,它只需删除脚本即可工作。但我想通过脚本使用该插件n我想让你帮助我为什么无法识别名称变量wn我添加了该脚本它工作正常w/退出它

    <?php $active = "";?>
<?php 
   include 'includes/header.php';
   include 'includes/event_functions.php';


?>
<?php 

if (isset($_GET['id'])) {
   $event =  get_event_by_id($_GET['id']);

   if ($event != null) {

?>

<div class="container"> 
<div class="clearfix" style="margin-top:20%;"> </div>

   <h1 style="color:#808080;text-align:center;"> Registering new event in afrisol  </h1>
<form method="post" action="updateevent.php" style = "margin-bottom:3%;" enctype="multipart/form-data">

   <div class="col-md-12"> 
          <div class="col-md-6">
     <div class="form-group">
       <label>
 Event start  date
       </label>
     </div>


     <div class="col-md-8">
    <div class="example">
        <input type="date" name="sdate" id="example1">

      </div>
     </div>

   </div>
   <div>
         <!-- date  -->
          <div class="col-md-6">
     <div class="form-group">
       <label>
        Event end date
       </label>
     </div>

     <div class="col-md-8">
     <div class="example">
    <input  type="date" class = "form-control" name ="ldate" id="ldate"  /></br></br>
     </div>
</div>
   </div class = "col-md-12">
          <div class="col-md-6">
     <div class="form-group">
       <label>
     Ticket start  date
       </label>
     </div>

     <div class="col-md-8">
    <input value= "<?php echo $event->tsdate;?>"  type="Date" class = "form-control" name ="tsdate" /></br></br>
     </div>

   </div>
          <!-- ticket date -->
           <div class="col-md-6">
     <div class="form-group">
       <label>
      Ticket end date
       </label>
     </div>

     <div class="col-md-8">
    <input value= "<?php echo $event->tldate;?>"  type="Date" class = "form-control" name ="tldate" /></br></br>
     </div>

   </div>
    </div>
    </div>


     <div class="col-md-8">
     <input  type="submit" class = "form-control" name ="submit" value="update" />

     </div>


   <!-- <input value=  type = "text" class = "form-control" name  = "daterange" value="01/01/2015- 01/31/2015" /> -->
     </div>

</form>
  <?php }} ?>
</div>


<?php 
   include 'includes/footer.php';
?>
<script>
      $(function() {
        $("#example1").dateDropdowns();



        // Set all hidden fields to type text for the demo
        $('input[type="hidden"]').attr('type', 'Date').attr('readonly','readoniy');
      });
    </script>
    <link href="js/Easy-Customizable-jQuery-Dropdown-Date-Picker-Plugin/demo/styles.css" rel="stylesheet">
<script  src ="js/Easy-Customizable-jQuery-Dropdown-Date-Picker-Plugin/dist/jquery.date-dropdowns.js"></script>

在afrisol中注册新事件
活动开始日期
活动结束日期


门票开始日期 $(函数(){ $(“#示例1”).dateDropdowns(); //将所有隐藏字段设置为键入演示文本 $('input[type=“hidden”]”).attr('type','Date').attr('readonly','readony'); });
在另一个页面“updateevent.php”中,我有这个源代码,以防

 <?php $active = "";?>
<?php

      include 'includes/header.php';
         include 'includes/util.php'; 
      include 'includes/event_functions.php';

?>
<div style="margin-top:15%;"></div>
<?php   
    if (isset($_POST['id']) ){



         // echo "string";

        $id = $_POST['id'];
        $title = $_POST['title'];
       $ldesc = $_POST['ldesc'];
       $desc = $_POST['desc'];
       $allowComment = $_POST['allowComment'];
       $level= $_POST['level'];
       $eBy = $_POST['by'];
       $country = $_POST['country'];
        $region = $_POST['Region'];
         $Town = $_POST['Town'];
       $kebele = $_POST['Kebele'];
       $Price = $_POST['price'];
       $video = $_POST['video'];
       $catagory = $_POST['catagory'];
       $longtude = $_POST['Longtude'];
       $lattitude = $_POST['lattitude'];
       $sdate = $_POST['sdate'];
       $edate = $_POST['ldate'];
       $tsdate = $_POST['tsdate'];
       $tedate = $_POST['tldate'];

   $update =   update_event( $id , $title, $ldesc, $desc, $allowComment,$level,$eBy,$country,$region,$Town,$kebele,$Price,$video,$catagory,$longtude,$lattitude,$sdate,$edate,$tsdate,$tedate );

      //echo $fName.$mName.$lName.$gender.$email.$phone;
         if ($update > -1) {
            /* header("Location  event_update_success.php?id=".$id);*/
              $event  = get_event_by_id($update);


         echo "<h1 style='color:green;text-align:center;'>you have updated successfully!!</h1>" ;
         echo "<h2 style='color:green;text-align:center;'>with those contents...</h2>"





?>
  <section id="blog" class="container">
        <div class="center">
            <h2> <?php echo $event->title; ?> </h2><hr/>

        </div>




        <div class="blog">
            <div class="row">
                <div class="col-md-2" style="width:230px;">
                    <div class="blog-item"> 

                            <div class="row">  
                                  <div class="col-md-12"  style="text-align:center;background:rgba(255,255,255,0.5);border=1px solid;border-radius:10px">

 <h2>About This Event </h2>
         <img src="<?php echo $event->image; ?>" style="height:250px;" class="img-responsive">

           <div class="col-xs-12 col-sm-12 text-center" style="border:1px solid #999;background:rgba(0,0,0,0.1);border-radius:10px;margin-top:10px;">
         <div class="entry-meta">
        <h3>Event By <b>Afrisol Events </b> </h3>
             <div id="publish_date" style="text-align:left;padding:8px "><div><i class="fa fa-user"></i>  posted by:-<p style="text-align:right;"><?php echo $event->by;?></p> </div></div>

              ***<span style="text-align:left;">
             <h2  style="text-decoration:underline;"> Event Dates</h2>
            <h3 style="color:#333;">Event Start Date:
            </h3><b><?php echo $event->sdate ;?></b>
            <h3 style="color:#333;">Event End Date:
           </h3> <b><?php echo $event->ldate ;?></b>
     <li>Ticket Start Date:
            <b><?php echo $event->tsdate ;?></b></li>
            <li> Ticket End Date:
            <b><?php echo $event->tldate ;?></b></li>-->***
           </span>
            <span style="text-align:left;"><h3>Event For:</h3><b><?php echo $event->level; ?> Membership</b></span>
           <span style="text-align:left;"><h3>Event Catagory : </h3><b><?php echo $event->catagory; ?> </b></span>


            <span style="text-align:left;"><h2 style="text-decoration:underline;">Location</h2>
            <h3>Country:</h3>
            <b><?php echo $event->country ;?></b>
            <h3>Region:</h3>
            <b><?php echo $event->Region ;?></b>
            <h3>City:</h3>
             <b><?php echo $event->Town ;?></b></span>

                           <!-- <span><i class="fa fa-heart"></i><a href="#">56 Likes</a></span> -->
                                    </div></div>

     <span style="text-align:left;"><h3>Map of Event Place</h3></span>
                                <iframe class="actAsDiv" width="100%" height="200" frameborder="0" scrolling="no" marginheight="0"
 marginwidth="0" src="https://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;q=<?php echo $event->lattitude?>%2C%20<?php echo $event->longtude?>&amp;aq=0&amp;ie=UTF8&amp;t=h&amp;z=16&amp;iwloc=A&amp;output=embed"></iframe>



</div>


                            </div>
                        </div><!--/.blog-item-->







                    </div><!--/.col-md-8-->
                    <div class="col-md-7" style="margin-left: 10px;background:rgba(255,255,255,0.7);border=1px solid;border-radius:10px">
      <div style="padding:10px 0px;"><img style="height:300px;width:100%;" src="<?php echo $event->image; ?>"  class="img-responsive"></div>
     <div>  <?php echo $event->desc;?></div>
       <!--<img src="uploads\profile\upload3470digitalManufacturing.jpg" > -->



      </div>

                <aside class="col-md-1" style="width:230px;margin-left: 10px;background-color:#fafafa;height:100%;">
                    <div class="col-md-12" style="margin:5px 0px;">
<div>
 <h2 style="text-align:center;"> AFrisol Events Advertizing Portion </h2>
 <img src="images/at-Afrisol.gif"  class="img-responsive" ></div>

   </div>
<div class="col-md-12" style="margin:5px 0px;">
 <div>
 <h2 style="text-align:center;"> Fasion Design Cotest Adama 2008 </h2>
 <img src="images/news/10X20_youthopia_Adama1.jpg"  class="img-responsive" >
         </div>
   </div>


                </aside>     

            </div><!--/.row-->

         </div><!--/.blog-->

    </section><!--/#blog-->








   <?php   }
           else{

             echo "<h2> Something Must went wrong  </h2>";

           }

       }


      // $passportNum = $_POST['passportNum'];
     //  $level = $_POST['level'];
?>

<?php
 include 'includes/footer.php';
?>

所以要完整地回答您的问题,可能的情况可能是

  • 将name属性添加到元素
  • 如果您正常过帐数据,请添加表单标记
  • 或者添加ajax代码以提交表单并将其添加到某个变量中,以便服务器端脚本可以使用它
如果需要帮助,请告诉我

谢谢
Amit

名称是元素在数据库中存储数据的强制属性。@AmitShah,除非他决定使用AJAX请求。如果您计划将值发布到另一个页面,请确保您的输入在
标记内,在ajax请求中,您需要在post数据中创建变量名,或者以其他方式将数据传递到服务器端脚本。您可以给我一些实例源代码吗!!我确实做了一个表单,给元素起了一个名字,然后我用名字n来称呼它,它说的是未定义的对象。但如果没有脚本,我的意思是只需要文本字段输入。我想现在我要明确说明这一点,并期待着你们的帮助