Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you are trying to shift all ascii codes of the symbols by one then your attempt to do it is not very good. Look at this code <a href="http://jsfiddle.net/AHgZq/" rel="nofollow">http://jsfiddle.net/AHgZq/</a></p> <pre><code>$('#in').keyup(function(){ var val = $(this).val(), newval = ''; for(var i=0; i&lt;val.length; i++) { newval += String.fromCharCode(val.charCodeAt(i)+1); } $('#out').val(newval); }); </code></pre> <p>On any letter entered in the input with id='in' it takes the whole string, takes every letter in it. Gets the ASCII code of it with function <code>charCodeAt</code>, increases it by one and converts back to ASCII symbol with the help of <code>fromCharCode</code> function. After that it sets the value of input with id='out' to that shifted string. Sample code uses jQuery for the fast access to the elements, but does not require it in general.</p> <p>Or you can do it with regexp <a href="http://jsfiddle.net/8sMvg/1/" rel="nofollow">http://jsfiddle.net/8sMvg/1/</a></p> <pre><code>$('#in').keyup(function(){ var val = $(this).val(), newval = ''; newval = val.replace(/(\w)/g, function(match,group){ return String.fromCharCode(match.charCodeAt(0)+1); }); $('#out').val(newval); }); </code></pre> <p>With respect to your code it will look like</p> <pre><code>function testResults (form) { var TestVar = form.inputbox.value; var NewVar = TestVar.replace(/(\w)/g, function(match){ return String.fromCharCode(match.charCodeAt(0)+1); }); alert ("Replaced text: " + NewVar); } </code></pre>
    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.
    1. VO
      singulars
      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