To find a Number of unique letters in string
<SCRIPT LANGUAGE="JavaScript">
function unique() {
var st = window.prompt("Enter string: ");
var arr=st.split("");
var resulted = new Array();
for (var j=0; j<arr.length; j ) {
var key = arr[j].toString();
if (!resulted[key]) {
resulted[key] = 1
} else {
resulted[key] = resulted[key] 1;
}
}
var str = "";
for (var j in results) {
if(resulted[j]==1){
str = j;
}
}
alert(str.length);
}
</script>
<input type="button" onclick="unique()" value="Click Me!"style="color:white; background-color:#FF9200;"
onmouseover="this.style.color='#999999'; this.style.backgroundColor='#F88017'"
onmouseout="this.style.color='white'; this.style.backgroundColor='#FF9200'"
onmousedown="this.style.color='white'; this.style.backgroundColor='#4E387E'"
onmouseup="this.style.color='black'; this.style.backgroundColor='#F88017'"/>
I provided onClick event for this function and this code not working properly, i mean in the prompt box if entered any letters or number it will goes out without alert or without prompt...!!