Split Textarea value to All Text Box & Query using string value

I made some function for split textarea value to all textarea and query using text string. I am able to success. But Some Problem. Below Example.

  1. Type to Filed1 string like:

  2. Then Click Split Button. Output: part all value to reaming text area.

  3. Put GF value to Input Character Filed. Output: 6589

  4. My Question is When i put value like GF then output 6589. And when put FG then also same output 6589 instead of 8965. If any solution Pls help me out. I wish to the Character strictly follow number.

 function splitText() {
      var textAreas = [];
      //Put all of the textareas into an array for easy access
      for(let i = 1; i <= 4; i++) {
      //Read the text from text1 and split it at a new line
      var text = textAreas[0].value;
      var [line1, line2] = text.split(/\r?\n/)
      for(let i = 0; i < 4; i++) {
      var combinedText = line1.substring(i, i+1) + line2.substring(i*2, (i+1)*2)
      textAreas[i].value = combinedText;
      var a=document.querySelectorAll('textarea');
      var str = $('#ccMain').val();
      var first = str[0];
      var second = str[1];
      console.log(first," ", second)
      var str='';
      <title>Test Demo</title>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
      <label>Filed1 </label>
      <textarea id="value1"></textarea>
      <textarea id="value2"></textarea>
      <textarea id="value3"></textarea>
      <textarea id="value4"></textarea>
      <button onclick="splitText()">Split!</button>
      <label>Input Character:</label>
      <input type="text" id="ccMain"  >
      <textarea id="output"></textarea>



Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us Javascript

©2020 All rights reserved.