1

Code is as follows:

function change_course(ref) 
{ 
      var arr = ref.split(/\^/);
  document.getElementById('course').value  = arr[0];
  document.getElementById('course_date').value  = arr[1]; 
}

This will throw an "Uncaught TypeError: object is not a function".

<select name="change_course" class="form-control" onChange="change_course(this.value);">';

Where is wrong

1 Answers1

2

Inline onchange is executed within the same scope as the form element (or inner), and change_course refers to the select element, not to the global function.

To fix this, just give a new value to select's name attribute, or rename the function.

Teemu
  • 22,918
  • 7
  • 53
  • 106
  • While the ` – Felix Kling Aug 31 '14 at 19:28
  • @FelixKling Looks like you're right, the wrapping form element is the one, where `change_course` is found. If the [form is stripped](http://jsfiddle.net/kehnckzq/), the error doesn't occur. – Teemu Sep 01 '14 at 04:47