2013-03-07 30 views
0

我在jQuerymobile頁面中創建了具有2個輸入文本字段的表單。但是,當點擊某個按鈕的時候,這個窗體的外部,我動態地在div「ratingInfo」裏添加了2個輸入框。在動態添加元素之後提交表單提交,而不是構建正確的查詢字符串

<form id="rate" method="GET" action="Ratings" data-ajax="false" onsubmit="return getRating();"> 
        <label for="regid">Enter Registration ID : </label> 
        <input type="text" placeholder="regid" id="regid" name="regid" data-mini="true" data-ajax="false" style="width:240px;"/> 
        <fieldset style="margin-top:30px;" data-role="controlgroup" data-type="horizontal" > 
         <legend>Rate the session our of 5 :</legend> 
         <input type="radio" name="radio" id="rating1" value="1" checked="checked"> 
         <label for="rating1">1</label> 
         <input type="radio" name="radio" id="rating2" value="2"> 
         <label for="rating2">2</label> 
         <input type="radio" name="radio" id="rating3" value="3"> 
         <label for="rating3">3</label> 
         <input type="radio" name="radio" id="rating4" value="4"> 
         <label for="rating4">4</label> 
         <input type="radio" name="radio" id="rating5" value="5"> 
         <label for="rating5">5</label> 
        </fieldset> 
        <div id="ratingInfo" style="margin-top:20px; margin-bottom:20px; color:rgb(177, 175, 175);"></div>     
        <button data-inline="true" data-rel="back" data-theme="c" type="reset" >Reset</button> 
        <button data-inline="true" data-transition="flow" type="submit" name="submit" id="submit" data-ajax="false" data-theme="b">Submit</button> 
      </form> 

jQuery的我在getRating()方法用來添加動態元素是:

$("#ratingInfo").empty(); 
$("#ratingInfo").append("<span >Session ID - </span><input type='text' style='width:240px; color:rgb(177, 175, 175);' name='eventId' id='eventId' disabled='true'>"); 
$("#eventId").val(eventId); 
$("#ratingInfo").append("<br/><span>Session Description - </span><input type='text' style='width:240px; color:rgb(177, 175, 175);' name='eventDesc' disabled='true' id='eventDesc'>"); 
$("#eventDesc").val(eventDesc); 

當我提交表單,查詢字符串(在URL)只有兩個參數即「regId」和「radio」。 其餘2個輸入字段「eventId」和「eventDesc」也不會添加到URL中。 但重置按鈕時,包括動態添加字段的所有字段也會重置。

什麼可能導致這個問題?

回答

0

截至目前,我已經解決了這個問題。

在「ratingInfo」div中,我創建了輸入元素。 對他們來說,我已經通過jQuery給出了值。

我已經加入樣式 「ratingInfo」 分區爲:

display:none; 

,以便它是不可見的。

謝謝。