All the good time! It is necessary when filling out the form on one page to transfer all its values ​​to one field textarea

<form role="form"> <div class="row"> <div class="col-md-5"> <div class="form-group"> <label for="number">Номер счета</label> <input type="text" class="form-control" id="number" placeholder="Например, №00006959"> </div> <div class="form-group"> <label for="title">Название товара</label> <input type="text" class="form-control" id="title" placeholder="Например, скрипт агрегации платежей UNIPAY"> </div> <div class="form-group"> <label for="sum">Итоговая стоимость, руб.</label> <input type="text" class="form-control" id="sum" placeholder="Только цифры, например, 1200"> </div> <div class="form-group"> <button type="submit" class="btn btn-primary waves-effect w-md waves-light mb-5">Сгенерировать ссылку </button> </div> </div> <div class="col-md-7"> <div class="form-group"> <label for="textArea">Платежная ссылка</label> <textarea id="textArea" class="form-control" rows="5"><?php echo base_url();?>pay/form/?</textarea> </div> </div> </div> </form> <!-- end row --> 

Grateful for any help!

  • those. it is necessary to add all the values ​​as text and then add the whole thing with the text in textarea ??? - xFloooo
  • Yes that's right! All values ​​must be in the textarea line - Anton Bogomolov

1 answer 1

 function foo(){ var x= document.getElementsByTagName("input"); document.getElementById("textArea").innerHTML = ""; for(var i=0;i<x.length;i++){ document.getElementById("textArea").innerHTML += x[i].value + "/"; } } 
 <form role="form"> <div class="row"> <div class="col-md-5"> <div class="form-group"> <label for="number">Номер счета</label> <input type="text" class="form-control" id="number" placeholder="Например, №00006959"> </div> <div class="form-group"> <label for="title">Название товара</label> <input type="text" class="form-control" id="title" placeholder="Например, скрипт агрегации платежей UNIPAY"> </div> <div class="form-group"> <label for="sum">Итоговая стоимость, руб.</label> <input type="text" class="form-control" id="sum" placeholder="Только цифры, например, 1200"> </div> <div class="form-group"> <button type="submit" class="btn btn-primary waves-effect w-md waves-light mb-5" onclick="foo();">Сгенерировать ссылку </button> </div> </div> <div class="col-md-7"> <div class="form-group"> <label for="textArea">Платежная ссылка</label> <textarea id="textArea" class="form-control" rows="5"> </textarea> </div> </div> </div> </form> <!-- end row --> 

  • I would like to add a comment to this answer, that for accurate work it would also be appropriate to add the textarea cleanup function when clicking on the "Generate link" button. - Legionary
  • all right, already added ... - C.Raf.T
  • thank! everything is working! - Anton Bogomolov