0

I am having an issue calling form() from my dropdown.

When I check the source, it shows the assist/form.js is being seen from the web-page.

I have copied and paste the form() the from page to the main page.

Here is an example of my Code. main page:

<script type="text/JavaScript" src="assist/form.js"></script>

<select name="field_type" onchange="form(this.value)">

assist/form page:

function form(type) {...}

Error I am getting following error:

Uncaught TypeError: form is not a function at HTMLSelectElement.onchange (index.php:32)

2
  • what do you mean by "is being seen"? does the form.js file define a global form function? does the JS resource import work (check in network tab of inspector)? Commented Apr 26, 2019 at 13:27
  • console.log(form) and you will see the conflict Commented Apr 26, 2019 at 13:27

1 Answer 1

4

You have a name collision

<form>
  <select onchange="console.log(form)">
    <option>1</option>
    <option>2</option>
  </select>
</form>

The console.log will show you that form will be the form you are in.

Rename your function to something else.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.