Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can a submittable online form recognize ( \t ) & ( \n ) delimiters and skip <input>'s when using copy-paste from Excel?
    primarykey
    data
    text
    <p>[[UPDATED AGAIN]] And I am sorry if this question gets wordy.</p> <p>I am a hobby coder, and I am looking for some help with syntax and functionality within javaScript which will allow copied delimiters such as "\t" and "\n" to skip appropriate <code>&lt;input&gt;</code>'s in an online form.</p> <p>I think I am about 33% there right now (again: hobby coder - self taught wanna be)</p> <pre><code>&lt;script type="text/javascript"&gt; function splitInput() { var x=document.forms["simpleForm02"]["dataInput_0"].value; var delimiterT = x.split("\t"); var delimiterN = x.split("\n"); for (var i=0;i&lt;delimiterT.length;i++) if (x.indexOf("\t") &gt;-1) { document.getElementById("dataInput_" + i ).value = (delimiterT[i]); } else for (var i=0;i&lt;delimiterN.length;i++) if (x.indexOf("\n") &gt;-1) { document.getElementById("dataInput_" + (i * 3) ).value = (delimiterN[i]); } } &lt;/script&gt; &lt;form name="simpleForm02"&gt; &lt;table&gt; &lt;tr&gt; &lt;th&gt;Color&lt;/th&gt; &lt;th&gt;Model&lt;/th&gt; &lt;th&gt;Qty&lt;/th&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;input class="colorInput" id="dataInput_0" name="colorInput_row_1" value="" onKeyUp="splitInput()"&gt;&lt;/td&gt; &lt;td&gt;&lt;input class="modelInput" id="dataInput_1" name="modelInput_row_1" value="" onKeyUp=""&gt;&lt;/td&gt; &lt;td&gt;&lt;input class="qtyInput" id="dataInput_2" name="qtyInput_row_1" value="" onKeyUp=""&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;input class="colorInput" id="dataInput_3" name="colorInput_row_2" value="" onKeyUp=""&gt;&lt;/td&gt; &lt;td&gt;&lt;input class="modelInput" id="dataInput_4" name="modelInput_row_2" value="" onKeyUp=""&gt;&lt;/td&gt; &lt;td&gt;&lt;input class="qtyInput" id="dataInput_5" name="qtyInput_row_2" value="" onKeyUp=""&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;input class="colorInput" id="dataInput_6" name="colorInput_row_3" value="" onKeyUp=""&gt;&lt;/td&gt; &lt;td&gt;&lt;input class="modelInput" id="dataInput_7" name="modelInput_row_3" value="" onKeyUp=""&gt;&lt;/td&gt; &lt;td&gt;&lt;input class="qtyInput" id="dataInput_8" name="qtyInput_row_3" value="" onKeyUp=""&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; </code></pre> <p>This code kinda works, in a limited way. If I copy three excel cells aligned side by side, and paste it into <code>&lt;input class="colorInput" id="dataInput_0" name="colorInput_row_1" value="" onKeyUp="splitInput()"&gt;</code>, then the script correctly splits and pastes the contents of the three cells across the top three inputs.</p> <p>However, I obviously have flaws in the script because it doesn't recognize the '\n' delimiter at all. And I also know that I have coding issues with the circumstance: applying the code to all cells relatively, and not just <code>["dataInput_0"]</code>.</p> <p>And lets presume I had the following data in an Excel sheet:</p> <p><img src="https://i.stack.imgur.com/O2iLs.png" alt="Screen capture of a simple data set in Excel"></p> <p>I am trying to find functionality that if I copied the Excel sample data above, it would overwrite/write the top 6 of the inputs in the sample <code>&lt;form name="simpleForm"&gt;</code>.</p> <p>Sorry to be long winded.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload