【发布时间】:2018-11-16 12:50:14
【问题描述】:
我真的迷路了,不知道该怎么办。 我试图将输入的 html 表单链接到 java-script 函数。
但问题是我不知道我的步骤是否正确。另一件事是如何在页面上显示输出。
function fnCountVowels(string) {
var getinput = document.getElementsbyid("Vowel1");
console.log(Vowel1.value);
for (i = 0 < getinput.length; i++) {
chr = getinput.charat(i);
if (Chr == "a" || (chr == "e") || (chr == "i") || (chr == "o") || (chr == "u")) {
getinput = getinput + 1;
}
}
return getinput;
}
<div id="Vowel" class="Tab">
<form action="" id="form" onsubmit="fnCountVowels(string)">
Enter String: <br>
<input id="Vowel1" type="text" name="Enter the string "><br><br>
<button type="submit" onclick"fnCountVowels(string)">Click</button>
</form>
【问题讨论】:
-
请对您的代码进行布局以使其可读。删除多余的空行并使缩进合理。
-
除了“我的代码不起作用,请帮忙”之外,这里还有什么具体问题吗?
标签: javascript html forms