duanqing2209 2011-07-14 16:09
浏览 61
已采纳

如何使用jquery将文本框添加到divved区域

Hi im using codeigniter PHP with jquery javascript function to create a textbox for time which is formatted.

I want the jquery function to add my textbox to the row of other textboxes instead of adding them to the bottom of the page.

Picture --> http://i.imgur.com/K9PiT.jpg

Here is my php file. It is messy I know but I am new to all of this.

        <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

Thanks

  • 写回答

1条回答

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 VS2019不能设置QT的verson了,设置了点确定又消失了,怎么解决呢?
      • ¥15 用java解决,要解释一下给我
      • ¥100 项目经理想学开发牛牛指点迷津有偿
      • ¥15 vscode 配置时出现问题
      • ¥15 pygame安装失败
      • ¥15 数据库原理怎么从文字描述中的句子推出(分析)函数依赖?
      • ¥15 想要使用有序logistic模型,因变量收集结果为以下,可以继续分析吗?
      • ¥15 C语言的问题 求尽快解答一下
      • ¥15 sql相关子查询的一道选择题
      • ¥15 关于图像检测的问题#