2012-10-11 3 views
0

내 문제는 아주 간단하지만 해결할 수 없습니다. js 함수를 통해 양식을 채우려고합니다. 여기 내 양식이다 (각 날짜, 사용자가 자신이 그 날에 무슨 짓을했는지 (동작을 입력 할 수 있습니다), 시간이 작업 (NbHour)에 소요) :이 채울 때양식 배열을 채울 수 없습니다.

<div id="hoursDetails" class="toogle_form" style="display:none"> 
     <table border=0> 
      <?php for ($i=0 ; $i<3; $i++){ 
     echo '<tr> 
        <td><div id="date'.$i.'" ></td> 
       <td><input type=text name="action'.$i.'" placeholder="Votre action"> 
       <input type="text" name="Nbhour'.$i.'" placeholder="nombre heures"> 
       </td> 
      </tr> 
     </table> ' ;} 
     ?> 

문제가 발생합니다 양식. 행동과 시간의 수 :

$('#date0').html('monday'); 
$('#date1').html('tuesday'); 
$('#date2').html('wednesday'); 

는 이상하게도,이 단지 두 개의 입력과 월요일을 보여줍니다 내가 JS 함수에서 어떻게 여기에있다. 두 번째 행의 경우 화요일에만 인쇄합니다. 그리고 세 번째 행은 존재하지 않습니다. 내가 뭘 잘못하고 있니?

답변

1

귀하의 마크 업은 유효하지 않습니다. 각 테이블에서 (</table>) 개의 테이블을 닫으면 반복됩니다. 테러는 마크 업을 깨뜨릴 것이다.

루프 밖으로 이동 </table> 닫습니다 hoursDetails

<div id="hoursDetails" class="toogle_form" style="display:none"> 
<table border=0> 
<?php for ($i=0 ; $i<3; $i++){ 
    echo '<tr> 
     <td><div id="date'.$i.'" ></div></td> 
     <td> 
      <input type=text name="action'.$i.'" placeholder="Votre action"> 
      <input type="text" name="Nbhour'.$i.'" placeholder="nombre heures"> 
     </td> 
    </tr>' ;} 
?> 
</table> 
</div> 
+0

<div>은 대단히 감사합니다 – user1499220

0

당신은

당신은이 div 개폐하지 않았다 당신의 <div> 태그를 닫을 필요 당신의 도움을 주셔서 감사합니다 :

<div id="hoursDetails" class="toogle_form" style="display:none"> 
0

당신은 divinput 태그를 닫지 않은, 어쩌면이 문제가 발생합니다 :

<div id="hoursDetails" class="toogle_form" style="display:none"> 
     <table border=0> 
      <?php for ($i=0 ; $i<3; $i++){ 
     echo '<tr> 
        <td><div id="date'.$i.'" ></div></td> 
        <td> 
         <input type=text name="action'.$i.'" placeholder="Votre action"/> 
         <input type="text" name="Nbhour'.$i.'" placeholder="nombre heures"/> 
       </td> 
      </tr> 
     </table> ' ;} 
     ?> 
관련 문제