HTML正文没有看到javascript

时间:2014-12-27 15:05:16

标签: javascript

似乎文件的正文在im ca.时没有看到javascript函数。我尝试了不同的方法:从头部应用一个函数(form.addEventListener(“submit”,submitEvent));和提交,但没有一个有效。你能帮我解决这个问题吗?

<html>
<head>
<Title>Adminostrative interface</title>
<meta charset="utf-8"/>



<script type="text/javascript"> 

function getInput(cssSelector){
    var input= ducument.querySelector(cssSelector);
    return input;
}

function submitEventAddTour(event){
    var count=true;
    var inp_nonD= getInput(".nonDigits");
    var inp_D= getInput(".digits");
    if((inp_nonD.value=="")|| (!isNaN(name.value)){
        count=false;
    }
       if((inp_D.value=="") || (isNaN(name.value)){
           count=false;
       }

          if(count==false){
              event.preventDefault();
              alert ("Incorrect input! Check each of the gaps");
          }
         }

       var form=getInput("formNewTour");
       form.addEventListener("submit", submitEvent);
</script>


</head>



<body>

<h3>Hello, <?php echo $_SESSION['name']; ?></h3>
<h3>Add new tour</h3>


<form method="POST" action="" class="formNewTour" >

<p><label>Country:</label>
 <input type="text" name="country" class="nonDigits" 
value= "<?php if(isset($error_country)){echo $_POST["country"];}?>"/>
</p>

<?php if (isset($error_country)){ echo $error_country;
               }  ?>


<p><label>Tour name:</label>
 <input type="text" name="tourName" class="nonDigits" 
value="<?php if(isset($error_tourName)){echo $_POST["tourName"];}?>"/>
</p>

<?php if (isset($error_tourName)){ echo $error_tourName;
               }  ?>

<p><label>Tour path:</label>
 <input type="text" name="path" class="nonDigits" 
value="<?php if(isset($error_path)){echo $_POST["path"];}?>"/>
</p>

<?php if (isset($error_path)){ echo $error_path;
               }  ?>


<p><label>Amount of days:</label>
 <input type="text" name="days" class="digits" value= "<?php if(isset($error_days)){echo $_POST["days"];}?>"/>
</p>
<?php if (isset($error_days)){ echo $error_days;
               }  ?>


<p><label>Hotel:</label>
 <input type="text" name="hotel" class="nonDigits" 
value="<?php if(isset($error_hotel)){echo $_POST["hotel"];}?>"/>
</p>

<?php if (isset($error_hotel)){ echo $error_hotel;
               }  ?>

<p><label>Hotel price(single room):</label>
 <input type="text" name="priceSingleRoom" class="digits"
value="<?php if(isset($error_priceSingleRoom)){echo $_POST["priceSingleRoom"];}?>"/>
</p>

<?php if (isset($error_priceSingleRoom)){ echo $error_priceSingleRoom;
               }  ?>

<p><label>Hotel price(double room):</label>
 <input type="text" name="priceDoubleRoom" class="digits"
value="<?php if(isset($error_priceDoubleRoom)){echo $_POST["priceDoubleRoom"];}?>"/>
</p>

<?php if (isset($error_priceDoubleRoom)){ echo $error_priceDoubleRoom;
               }  ?>

<p><label>Breakfast price:</label>
 <input type="text" name="priceBreakfast" class="digits"
value="<?php if(isset($error_priceBreakfast)){echo $_POST["priceBreakfast"];}?>"/>
</p>

<?php if (isset($error_priceBreakfast)){ echo $error_priceBreakfast;
               }  ?>

<p><label>Lunch price:</label>
 <input type="text" name="priceLunch" class="digits"
value="<?php if(isset($error_priceLunch)){echo $_POST["priceLunch"];}?>"/>
</p>

<?php if (isset($error_priceLunch)){ echo $error_priceLunch;
               }  ?>

<p><label>Dinner price:</label>
 <input type="text" name="priceDinner" class="digits"
value="<?php if(isset($error_priceDinner)){echo $_POST["priceDinner"];}?>"/>
</p>

<?php if (isset($error_priceDinner)){ echo $error_priceDinner;
               }  ?>


<p><label>Total tour price: </label>
<input type="text" name="totalTourPrice" class="digits"
value="<?php if(isset($error_totalTourPrice)){echo $_POST["totalTourPrice"];}?>"/>
</p>

<?php if (isset($error_totalTourPrice)){ echo $error_totalTourPrice;
               }  ?>

<input type="submit" value="Add new tour" name="submitNewTour"/>
</p>


</form>



<form method="POST" action="" class="formNewDate">
<p>Add new date: Tour name: <input type="text" name="newDateTour" 
value="<?php if(isset($error_newDateTour)){echo $_POST["newDateTour"];}?>"/>

Date: <input type="text" name="newDate" 
value="<?php if(isset($error_newDate)){echo $_POST["newDate"];}?>"> 

Amount of places:<input type="text" name="places" 
value="<?php if(isset($error_newPlaces)){echo $_POST["places"];}?>"/></p>

<p><input type="submit" value="Add new date" name="addDate"/></p>

<p><?php if (isset($error_newDateTour)){ echo $error_newDateTour;
               }  ?></p>
<p><?php if (isset($error_newDate)){ echo $error_newDate;
               }  ?></p>
</p><?php if (isset($error_newPlaces)){ echo $error_newPlaces;
               }  ?></p>



</form>

0 个答案:

没有答案