2011-07-14 4 views
0

こんにちは私はフォーマットされた時間のテキストボックスを作成するjqueryのjavascript関数でcodeigniter PHPを使用しています。jqueryを使用して分割された領域にテキストボックスを追加する方法

jquery関数を使用して、テキストボックスをページの下部に追加するのではなく、他のテキストボックスの行に追加します。

ピクチャー - >http://i.imgur.com/K9PiT.jpg

ここでは私のPHPファイルです。それは私が知っている乱雑ですが、私はこのすべてに新しいです。

 <script type="text/javascript"> var i = 0; </script> 

<?php 
     for ($i=0; $i< 20; $i++) 
     { 


?> 

    <script type="text/javascript">  

     var input = $("<input>", { //this bit will be removed in the form 
       name: 'time'+i, 
       val: '00:00:00', 
       maxlength: '8', 
       size: '5' 
      }); 
      i++; 
      input.click(function() { 

       $(this).prop({ 
        selectionStart: 0, 
        selectionEnd: 0 
       }); 

      }).keydown(function() { 

       var sel = $(this).prop('selectionStart'), 
        val = $(this).val(), 
        newsel = sel === 2 ? 3: sel; 
        newsel = sel === 5 ? 6: newsel; 

       $(this).val(val.substring(0, newsel) + val.substring(newsel + 1)) 

       .prop({ 
        selectionStart: newsel, 
        selectionEnd: newsel 
       }); 
      }); 

      $('body').append(('#timearea_DIV').html()); 

     </script> 

      <?php 
     echo '<div id="timearea"></div> //THIS IS WHERE THE jquery generated textboxes must go!'; 

    //the event itself 
      echo form_input ('event'.$i , set_value ('event'.$i)); 
    //supplies used 
      echo form_input ('supplies'.$i, set_value ('supplies'.$i)); 
    //what is the manufacturer 
      echo form_input ('manufacturer'.$i, set_value ('manufacturer'.$i)); 
    //quantity 
      echo form_input ('quantity'.$i, set_value ('quantity'.$i)); 
    //was the event successful? 
      echo form_dropdown ('success'.$i, $yesno , set_value ('success'.$i)); 
    //comment if necessary 
      echo form_input ('comment'.$i , set_value ('comment'.$i)); 
    echo '<br/>'; 
    } 

     //end of for loop 

おかげ

+1

グーグルのためのその後

、彼らは何もしません! –

+0

私はそれをdivに追加することができましたが、今はちょうど行かれています。 – giedrere

+0

[tag:php]が[tag:javascript]/[tag:jquery]の質問に関連していると仮定しているのはなぜですか? @giedrere、** [tag:html] **( 'view source'から)を表示してください。 –

答えて

1

あなたは身体oをそれに追加されます! このテキストボックスを追加するIDを持つ空のdivを配置します。そのdivの

(#divid).html('text box you want to add') 

またはappendそのdiv要素に

+0

ありがとう、私はそれを理解しましたが、問題は、その行を1行に追加することです、私は私のphp forループが正しく動作していないと思う – giedrere

関連する問題