2012-08-27 59 views
0

我試圖使用jQuery中
追加這樣的CakePHP和jQuery追加

$('.div_addfield').append('<?php echo $this->Form->input("dob",array("separator"=>"","type"=>"date","label"=>"Date of Birth"));?>'); 

它不是Firebug的工作控制檯它givee follwing錯誤

SyntaxError: unterminated string literal

但它顯示如下陣列

$('.div_addfield').append('<select id="ListOfStudentListOfHouseId" name="data[ListOfStudent]['+field_count+'][list_of_house_id]"><option value="1">Aitchison</option><option value="2">Nalagarh</option><option value="4">Ranjit</option><option value="5">Patiala</option></select>'); 
$('.div_addfield').append('<div class="input date"><label for="dobMonth">Date of Birth</label><select name="data[dob][month]" id="dobMonth"> 
<option value="01">January</option> 
<option value="02">February</option> 
<option value="03">March</option> 
<option value="04">April</option> 
<option value="05">May</option> 
<option value="06">June</option> 
<option value="07">July</option> 
<option value="08" selected="selected">August</option> 
<option value="09">September</option> 
<option value="10">October</option> 
<option value="11">November</option> 
<option value="12">December</option> 
</select><select name="data[dob][day]" id="dobDay"> 
<option value="01">1</option> 
<option value="02">2</option> 
<option value="03">3</option> 
<option value="04">4</option> 
<option value="05">5</option> 
<option value="06">6</option> 
<option value="07">7</option> 
<option value="08">8</option> 
<option value="09">9</option> 
<option value="10">10</option> 
<option value="11">11</option> 
<option value="12">12</option> 
<option value="13">13</option> 
<option value="14">14</option> 
<option value="15">15</option> 
<option value="16">16</option> 
<option value="17">17</option> 
<option value="18">18</option> 
<option value="19">19</option> 
<option value="20">20</option> 
<option value="21">21</option> 
<option value="22">22</option> 
<option value="23">23</option> 
<option value="24">24</option> 
<option value="25">25</option> 
<option value="26">26</option> 
<option value="27" selected="selected">27</option> 
<option value="28">28</option> 
<option value="29">29</option> 
<option value="30">30</option> 
<option value="31">31</option> 
</select><select name="data[dob][year]" id="dobYear"> 
<option value="2032">2032</option> 
<option value="2031">2031</option> 
<option value="2030">2030</option> 
<option value="2029">2029</option> 
<option value="2028">2028</option> 
<option value="2027">2027</option> 
<option value="2026">2026</option> 
<option value="2025">2025</option> 
<option value="2024">2024</option> 
<option value="2023">2023</option> 
<option value="2022">2022</option> 
<option value="2021">2021</option> 
<option value="2020">2020</option> 
<option value="2019">2019</option> 
<option value="2018">2018</option> 
<option value="2017">2017</option> 
<option value="2016">2016</option> 
<option value="2015">2015</option> 
<option value="2014">2014</option> 
<option value="2013">2013</option> 
<option value="2012" selected="selected">2012</option> 
<option value="2011">2011</option> 
<option value="2010">2010</option> 
<option value="2009">2009</option> 
<option value="2008">2008</option> 
<option value="2007">2007</option> 
<option value="2006">2006</option> 
<option value="2005">2005</option> 
<option value="2004">2004</option> 
<option value="2003">2003</option> 
<option value="2002">2002</option> 
<option value="2001">2001</option> 
<option value="2000">2000</option> 
<option value="1999">1999</option> 
<option value="1998">1998</option> 
<option value="1997">1997</option> 
<option value="1996">1996</option> 
<option value="1995">1995</option> 
<option value="1994">1994</option> 
<option value="1993">1993</option> 
<option value="1992">1992</option> 
</select></div>'); 

任何人都知道如何解決這個錯誤

感謝

回答

0

嘗試使用此

$('.div_addfield').append('<?php echo str_replace(array("\r\n", "\r", "\n"), "",$this->Form->input("dob",array("separator"=>"","type"=>"date","label"=>"Date of Birth")));?>'); 
0

你不能有一個字符串中跨越JavaScript的多條線路,雖然可以在該行的末尾添加一個\和字符串將繼續下一行。