- Posts: 125
- Thank you received: 3
Ask the community, share ideas, and connect with other LimeSurvey users!
$supp = array('À', 'Á', 'Â'); $replace = array('A', 'A', 'A'); str_replace($supp, $replace, $str);
str_replace("é", "e", str_replace("É", "E", str_replace("è", "e", str_replace("È", "E", q4_SQ001))))
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Identify some elements var thisQuestion = $('#question{QID}'); var input1 = $('li.question-item:eq(0) input.text', thisQuestion); var input2 = $('li.question-item:eq(1) input.text', thisQuestion); // Hide the second input //$('li.question-item:eq(1)', thisQuestion).hide(); // Listener on the first input input1.on('keyup', function(e){ repSpecChars(); }); input1.on('paste', function(e){ setTimeout(function () { repSpecChars(); }, 100); }); // A function to replace special characters function repSpecChars(str) { // The character arrays (must be same length var specialChars = ["ù", "Ù", "û", "Û", "à", "Â", "ç", "Ç", "é", "É", "è", "È", "ê", "Ê", "î", "Î", "ô", "Ô"]; var nonSpecialChars = ["u", "U", "u", "U", "a", "A", "c", "C", "e", "E", "e", "E", "e", "E", "i", "I", "o", "O"]; var input1Val = input1.val().toString(); $(specialChars).each(function(i){ input1Val = input1Val.replace( new RegExp(specialChars[i], 'g'), nonSpecialChars[i] ); }); input2.val(input1Val); } }); </script>
Feature request ?tpartner wrote: Well,it seems that str_replace() doesn't work with arrays in Expression Manager.
....
str_replace(['À', 'Á', 'Â'], ['A', 'A', 'A'], QUESTION);