2017-01-10 33 views
0

嗨,所以即時通訊相當新的HTML和JavaScript,即時通訊嘗試創建這個簡單的計算器 - 用戶輸入小時,它返回用戶的各種數量的東西,如平均小時等表單後 - 如何獲得網址

我想使用post方法來提交數據,但即時通訊困惑,如何獲得使用的網址,如果我只是寫在崇高的文本中的HTML文件?以下是html代碼。

我已經閱讀了許多有關客戶端/服務器交互的網站,但我仍然對如何去做這件事感到困惑。提前致謝!

<form action="????????" method="post"> 
 

 
    <div class="initialdata"> 
 
    Total employees in office: 
 
    <br> 
 
    <input type="text" name="totalemployees"> 
 
    <br>Total work hours in a day: 
 
    <br> 
 
    <input type="text" name="workhours"> 
 
    <br> 
 
    </div> 
 

 
    <!--- *************************Display table for inputting data************************* --> 
 
    <div class="hours"> 
 
    <table> 
 
     <tr id='addr0'> 
 
     <td> 
 
      <input type="number" name="avgHours[]" min="0"> 
 
     </td> 
 
     </tr> 
 
     <tr> 
 
     <td> 
 
      <input type="number" name="avgHours[]" min="0"> 
 
     </td> 
 
     </tr> 
 
     <tr> 
 
     <td> 
 
      <input type="number" name="avgHours[]" min="0"> 
 
     </td> 
 
     </tr> 
 
     <tr> 
 
     <td> 
 
      <input type="number" name="avgHours[]" min="0"> 
 
     </td> 
 
     </tr> 
 
     <tr> 
 
     <td> 
 
      <input type="number" name="avgHours[]" min="0"> 
 
     </td> 
 
     </tr> 
 
     <tr> 
 
     <td> 
 
      <input type="number" name="avgHours[]" min="0"> 
 
     </td> 
 
     </tr> 
 
     <tr> 
 
     <td> 
 
      <input type="number" name="avgHours[]" min="0"> 
 
     </td> 
 
     </tr> 
 
     <tr> 
 
     <td> 
 

 
      <!--- ***************** Add row button ******************** --> 
 
      <button type="button" id="addrow" title="Add row" class="ar"> 
 
      Add row 
 
      </button> 
 
      <!--- *********************** CALCULATE button ************************** --> 
 

 
      <input class="button" value="Calculate" type="submit" /> 
 
</form>

enter image description here

回答

0

,如果你只使用JavaScript構建你的程序,你不需要發送請求到服務器,您的代碼將客戶端機器上由JavaScript

<script> 
</script> 
之間運行

標籤,你需要聽按鈕上的動作addEventListener方法