dongwang6837 2019-01-25 07:47
浏览 105
已采纳

Javascript - 如何将文本区域的值发送到我的文本框

I want to send the value of the text area to the textbox. the text area value is get from the qr-code once it is scanned. so i want to send the textarea value to the textbox value

 <?php
 if(isset($_POST['btnSubcode'])) {
      $lblCode  =  isset($_POST['lblQrTxt']) ? $_POST['lblQrTxt'] : '';

      $code = $lblCode;
      $code = explode(":",$code); // code = array("QR Code","444444444|123")
      $code = explode("|",$code[1]); // code[1] = "444444444|123"
      $code = trim($code[0]); // 444444444

      $code2 = $lblCode;
      $code2 = explode(":",$code2); // code = array("QR Code","444444444|123")
      $code2 = explode("|",$code2[1]); // code[1] = "444444444|123"
      $code2 = trim($code2[1]); // 123
 }
 ?>

 <div class="form-group">
      <label class="form-control-label">code</label>
      <input type="text" id="card-code" value='<?php echo $code ?>' class="form-control">
 </div>

 <div class="col-md-4">
      <div class="form-group">
           <label class="form-control-label">pin</label>
           <input type="text" id="card-pin" value='<?php echo $code2 ?>' class="form-control" maxlength="3">
      </div>
 </div>
 </form>

///////////////////////////////THIS IS THE TEXT AREA///////////////////////
         <textarea class="form-control text-center" id="scanned-QR" name="lblQrTxt"></textarea><br><br>
                               <input class="btn btn-primary btn-lg" type="submit" name="btnSubcode"></input>

there is my code, so the value comes in the textarea. so when the value is set i want an automatic transfer on the textbox.

  • 写回答

3条回答 默认 最新

  • dragon8899 2019-01-25 07:55
    关注

    It seems you need something like this:

    $('#scanned-QR').on('change textInput input', function () {
        var val = this.value;
        $("input[name=input]").val(val);
    });
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <textarea class="form-control text-center" id="scanned-QR" name="lblQrTxt"></textarea><br><br>
    <input type="text" name = "input"></input>

    </div>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥30 python代码,帮调试,帮帮忙吧