Hi,
I need to convert string to char array?
For example, if string ADNAAN, I want output A-D-N-A-A-N.
Please help.
This way you can do
<input type="button" onclick="CharArray()" value="To Array" /> <span id="spnName">ADNAAN</span> <script> function CharArray() { var name = document.getElementById("spnName").innerHTML; var chars = name.split(''); name = ''; for (var i = 0; i < chars.length; i++) { name += chars[i] + "-"; } name = name.substring(0, name.length - 1); document.getElementById("spnName").innerHTML = name; }; </script>
Demo
© COPYRIGHT 2025 ASPSnippets.com ALL RIGHTS RESERVED.