2013-03-07 29 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; 

,以便它是不可见的。

谢谢。