Javascript – I keep getting a “Uncaught TypeError: string is not a function” error, even though the code seems to be fine. Can anyone have a look and explain


    <script language = javascript>
    show = function()
         document.getElementById("name").innerHTML =;
         var app = document.getElementById("app");
         var apps =;

         for (a in apps)
              var appAdd = document.createElement("option");
              appAdd.text = apps[a];
              appAdd.value = apps[a];


    accept = function()
        var app = document.getElementById("app");

        window.opener.input.options = "acceptApp"; = app.options[app.selectedIndex].value;

    <body onload = "show()">
        <h1 id = "name" align = "center"> ### </h1>
    <div style="text-align:center">
            <p>You own this guild.</p>

        <select id = "app"></select>

        <input type = "button" onclick = "accept()" value = "Accept application" />

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.

Best Solution

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...

Related Question