很抱歉,如果已经解决了...我正在尝试从基本文本输入表单传递信息,然后使用其他几个函数解析该信息。我无法弄清楚如何从onClick属性中的函数返回信息以将其传递给另一个函数。
function getBulletaction(element) {
return element[0].value;
}
// why can't i store this in a variable outside of the function???
let valueFrmForm = getBulletaction(document.getElementById("frmForm"));
document.getElementById("log").innerHTML = valueFrmForm;
//I want to pass the value returned from getBulletaction() to getaction() which will change the user input to lowercase characters.
function getaction(OutOfTheFunction){
let action = userInput.toLocaleLowerCase('en-US');
return action;
}
<form name="bulletForm" id="frmForm">
Write the action of your bullet:<br>
<input type="text" name="bulletaction" value="" style="width: 30%;"/>
<input type="button" name="submitType" value="Submit" onClick="getBulletaction(this.parentElement)" />
</form>
<h3>This is where the data is supposed to appear from getBulletaction()</h3>
<p id="log"></p>