2016-08-28 74 views
2

我試圖發送一個http請求到一個網站,我需要用戶填寫他們的名字和手機號碼。我試圖做到這一點的跟着(我還在工作的驗證功能,所以現在它總是返回false。)html兩個輸入值得到交換

<html> <meta charset="UTF-8" /> 

<script type="text/javascript"> 

    function validate(){ 
     var a = document.forms["sendform"]["mobile"].value; 
     alert(a); 

     return false; 
    } 

</script> 

/*<style> 

.myButton { 
    background-color:#4a45c7; 
    -moz-border-radius:28px; 
    -webkit-border-radius:28px; 
    border-radius:28px; 
    border:1px solid #193eab; 
    display:inline-block; 
    cursor:pointer; 
    color:#ffffff; 
    font-family:Arial; 
    font-size:17px; 
    padding:16px 31px; 
    text-decoration:none; 
    text-shadow:0px 1px 0px #282b66; 
    position: absolute; 
    top: 50%; 
    left: 45%; 
} 

.userNameField{ 
    position: absolute; 
    top: 45%; 
    left: 45%; 
} 

.userEmailField{ 
    position: absolute; 
    top: 40%; 
    left: 45%; 
} 

.userMobileField{ 
    position: absolute; 
    top: 35%; 
    left: 45%; 
} 

.userName{ 
    position: absolute; 
    top: 32.5%; 
    left: 38%; 
} 

.userEmail{ 
    position: absolute; 
    top: 37.5%; 
    left: 38%; 
} 

.userMobile{ 
    position: absolute; 
    top: 42.5%; 
    left: 38%; 
}*/ 

</style> 

    <body> 
     <?php 

     $stcate = $_POST["stCate"]; 
     $stcode = $_POST["stCode"]; 
     $result = $stcate . $stcode; 
     ?><br> 
      <form name="sendform" id = "sendform" method="post" action="https://www.ezship.com.tw/emap/ezship_request_order_api.jsp" onsubmit="return validate();"> 


      <p class = "userName"> 取件人姓名 </p> 
      <input type="text" name="rv_name" id = "name" class = "userNameField"/> <br> 

      <p class = "userMobile"> 取件人電話</p> 
      <input type="text" name="rv_mobile" id = "mobile" class = "userMobileField"/> <br> 


      <input type="hidden" name="st_code" value= "<?php echo $result;?>"/> 
      <input type="hidden" name="rv_addr" value="" /> 
      <input type="hidden" name="rv_zip" value="" /> 
      <input type="hidden" name="rtn_url" value='http://localhost/orderstatus.php' /> 
      <input type="hidden" name="web_para" value='yes' /> 

      <input type="submit" class = "myButton" value='確認寄出' /> 

     </form> 


    </body> 
</html> 

後,我進入了一些值輸入和點擊發送,警報始終打印輸入「名稱」的值,即使我試圖打印輸入「移動」。當我嘗試打印出「name」的值時,會發生同樣的情況,它只是打印出「name」的值。我不明白爲什麼值被交換?我嘗試了它,沒有任何PHP代碼和CSS,它的工作方式我期望。我究竟做錯了什麼?

+0

考慮刪除了'''