<html>
<head>
<script language = javascript>
show = function()
{
document.getElementById("name").innerHTML = window.opener.game.pl.guild.n;
var app = document.getElementById("app");
var apps = window.opener.game.pl.guild.app;
for (a in apps)
{
var appAdd = document.createElement("option");
appAdd.text = apps[a];
appAdd.value = apps[a];
app.add(appAdd);
}
}
accept = function()
{
console.log("Accepting");
var app = document.getElementById("app");
window.opener.input.options = "acceptApp";
window.opener.input.an = app.options[app.selectedIndex].value;
}
</script>
</head>
<body onload = "show()">
<h1 id = "name" align = "center"> ### </h1>
<div style="text-align:center">
<p>You own this guild.</p>
</div>
</br>
<p>Applications:</p>
<select id = "app"></select>
<input type = "button" onclick = "accept()" value = "Accept application" />
</body>
</html>
Every time a user clicks the button, the accept function should be called. There's nothing wrong with the function itself, I'm sure about that. The function show that gets called when this starts just fills the selection with options, and create just sends it to the server.
The TypeError: "x" is not a function can be fixed using the following suggestions: Paying attention to detail in code and minimizing typos. Importing the correct and relevant script libraries used in code. Making sure the called property of an object is actually a function.
According to the Mozilla website for developer documents, “the TypeError object represents an error when a value is not of the expected type.” Uncaught means that the error was not caught in the catch part of the try-catch block.
Kelly M. - September 27, 2020. The $ sign in jQuery is a syntax commonly used as a shortcut to access or define a JavaScript library. The code below illustrates that invoking the $ sign or the jQuery method results in all the <p> tags in a document.
You should put a semi-colon after the function call in your events:
onload = "show();"
onclick = "accept();"
Edit: I also see in these similar SO questions that there can be problems with function names that cause this exact error message. Just for fun, you might try renaming your functions...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With