2013-03-23 69 views
0

在phonegap中,我使用了一個jQuery移動框架。我想通過使用頁面url將表單數據傳遞到下一頁,這是一個div。我嘗試使用GetElementByID來檢索參數searchlocation。它可能無法工作。該參數不能被檢索,並且不能進入下一頁。我該如何解決它?從表單獲取參數

樓下是改變下頁DIV功能是我的PhoneGap的代碼:

<script type="text/javascript"> 
$('#home').live('pagecreate',function(event) { 
$("#form").submit(function (e) { 
     e.preventDefault(); 
     var x=document.getElementById("searchlocation"); 
     $.mobile.changePage("#page1?param1="+x); 
    }); 
}); 
</script> 

而且HTML表單:

<form id="form" method="POST" action="page1" data-ajax="false"> 
       <div data-role="fieldcontain" id="search"> 
        <fieldset data-role="controlgroup"> 
         <label for="search"> 
          Search 
         </label> 
         <input name="searchword" id="searchword" placeholder="" value="" type="search" /> 
        </fieldset> 
       </div> 
       <div data-role="fieldcontain" id="searchcondition"> 
        <label for="searchmethod"> 
        </label> 
        <select id="searchmethod" name="searchmethod" data-theme="e"> 
         <option value="keyword"> 
          Keyword 
         </option> 
        </select> 
       </div> 
       <div data-role="fieldcontain2" id="searchcondition2"> 
        <label for="searchlocation2"> 
        </label> 
        <select id="searchlocation" name="searchlocation" data-theme="e"> 
         <option value="Entire Collection"> 
          Entire Collection 
         </option> 
         <option value="Pearl River Delta and Yangtze River Delta Collection"> 
          Pearl River Delta and Yangtze River Delta Collection 
         </option> 
        </select> 
       </div> 
       <input type="submit" value="Submit" /> 
      </form> 

回答

0
var x = document.getElementById("searchlocation"); 

上面的代碼獲取元素,而不是價值。

考慮你正在使用jQuery你可以使用:

var x = $('#searchlocation').val();