Count the vowels of an input?

后端 未结 6 1971
小鲜肉
小鲜肉 2021-01-27 10:25

Hi I am trying to count the vowels of the input of the form in my HTML using javascript currently with no success.

Here is my HTML


         


        
6条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-27 11:15

    Two problems:

    1) You're missing colons after each case statement. I.e., it should be

    case 'a': case 'b': etc.

    not

    case 'a'
    case 'b'
    

    2) You seem to be assuming that your click event will pass the form that the button is in to the function vow. It doesn't.

    Just change this:

    function vow(form){
        var a = form.CountVowels.value;
    

    To:

    function vow(){
        var a = document.getElementById("input1").value;
    

    Also, you should really be programming with your Console window open to see JS errors. You would have seen both of those issues.

提交回复
热议问题