【问题标题】:Multiple input smoothly [closed]多个输入顺利[关闭]
【发布时间】:2016-01-18 06:40:54
【问题描述】:

我需要一个需要多次重复这样一行的表单。行由文本字段、单选框、复选框、选择框所有类型的输入字段组成。输入第一个输入字段后,只需按 Enter,光标应显示在下一个字段上。应添加添加按钮以添加每一行。提交表单后数据应该保存在mysql DB中。

查看下面的屏幕截图:- enter image description here

【问题讨论】:

  • 请查看article
  • 感谢分享链接,但是这部分在给定的链接中没有解决“光标应该通过按回车显示在下一个字段上”,所以,请立即删除负面反馈(大拇指向下)
  • 本文分享概念动态添加字段并提交值到mySql DB。现在关于cursor should be shown on next field by pressing just enter
  • 你说的是什么意思,请立即删除负面反馈(不赞成)

标签: php mysql forms


【解决方案1】:

我使用了类似您的要求的东西。希望这对您有用。

          <div class="form-group" id="text1">
            <label for="name" class="col-sm-3 control-label">Long/Lat</label>
            <div class="col-sm-7" id="p_scents1">
              <p>
                <!-- <div class="col-sm-6"> -->
                <input type="text" name="fname[]" id="fname" class="col-sm-3 form-control1" placeholder="Enter firstname">
                <!-- </div> -->
                <!-- <div class="col-sm-6"> -->
                <input type="text" name="lname[]" id="lname" class="col-sm-3 form-control1"   placeholder="Enter lastname">
                <!-- </div> -->
                <input type="text" name="location[]" id="location" class="col-sm-3 form-control2" placeholder="Enter location">
              </p>
            </div>
            <div class="col-sm-2">
              <a href="#" id="addScnt1" >+ Add More</a>
            </div>
          </div>

          <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<script>
  $(document).ready(function() {        
//alert("hret");
    var scntDiv1 = $('#p_scents1');
    var i = $('#p_scents1 p').size() + 1;

    $('#addScnt1').live('click', function() {

            $('<p><input type="text" id="fname'+i+'" size="20" name="fname[]' + i +'" value="" placeholder="Enter firstname" class="col-sm-3 form-control1"/><input type="text" id="lname'+i+'" size="20" name="lname[]' + i +'" value="" placeholder="Enter lastname" class="col-sm-3 form-control1"/><input type="text" id="location'+i+'" name="location[]' + i +'" class="col-sm-3 form-control2" placeholder="Enter location"><a href="#" id="remScnt1">Remove</a></p>').appendTo(scntDiv1);
            i++;
            return false;
    });

    $('#remScnt1').live('click', function() { 
      //alert(i);
            if( i > 2 ) {
                    $(this).parents('p').remove();
                    i--;
            }
            return false;
    });
});
</script>

祝你好运!

【讨论】:

  • 谢谢,但我想动态输入,选择框(来自mysql数据库)一行需要重复多次。我无法正确插入数据库
  • 使用 ajax 从数据库中动态获取数据并将这段代码和那段代码一起添加,这样您就可以动态获取和添加行。
  • 哦老兄!!我需要完整的解决方案!!!!我找到了你提供的所有代码。
  • @RidwanulHoque 您需要完整的解决方案吗?然后自己编码。 Stack Overflow 不是一个让开发人员免费完成工作的网站。
  • 这不是一个完整的项目,只是我需要帮助的一部分。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多