select onChange not working inside a form
I found that as you set name
and id
attribute same of your function name causing this conflict and prompting error viewroom
is not a function, change the name of function. also define your js at the bottom of document.
function viewRoom()
{
alert(123);
}
Working Demo
Your function name conflicts with name
and id
of the select
, just give another name to the function.
You can't name a function the same as an element on your page. I suggest changing the function name to something like viewroomSelected
as shown here in this jsFiddle.
Relevant changes:
function viewroomSelected()
{
alert(123);
}
<select name="viewroom" id="viewroom" onChange="viewroomSelected()">