Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I send textbox values to javascript function?
    primarykey
    data
    text
    <p>I seem to be doing something wrong here. This script works with the prompts, which have been commented out, but not with the textboxes. Am I somehow failing to send the input values to the function? </p> <p>I'm also having trouble using regular expressions in the if-statements, rather than a clumsy list of punctuation marks.</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="myTypingText"&gt;&lt;/div&gt; &lt;label&gt;Say what you want typed&lt;/label&gt; &lt;input class="textBox" id="userInput" /&gt; &lt;label&gt;A pregnant pause... (300?)&lt;/label&gt; &lt;input type="number" id="userBreath" /&gt; &lt;button onclick="printLooper()" href="javascript:;"&gt;Submit&lt;/button&gt; &lt;! --input name="buttonExecute" onclick="execute(document.getElementById('textbox1').value)" type="button" value="Execute" --/&gt; &lt;script type="text/javascript" language="javascript"&gt; var myString = document.getElementById('userInput').value; //var myString = prompt('Say what you want to see typed','Right here, baby'); //prompts are annoying, i know //var myDelay = prompt('Type speed (try 50)', 'The higher the number, the slower it types'); //var myBreath = prompt('Now tell me how long to pause at each breath (shift+2)', 'Try 300') var myBreath = document.getElementById('userBreath').value; var myArray = myString.split(""); var loopTimer; function printLooper(){ if(myArray.length &gt; 0 ){ var char = myArray.shift(); if ( char === '@'){ document.getElementById("myTypingText").innerHTML }else { document.getElementById("myTypingText").innerHTML += char; } } else { clearTimeout(loopTimer); } if (char === ' '){ loopTimer = setTimeout('printLooper()', 20); } else if (char === ',' || char === '.' || char === '?') { loopTimer = setTimeout('printLooper()', 220); //fiddle with these 2nd params as you see fit } else if (char === '@'){ loopTimer = setTimeout('printLooper()', myBreath); } else { loopTimer = setTimeout('printLooper()', 47); } } printLooper(); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Any help appreciated!</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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