0

I had been getting this message when I use a JavaScript function for the onchange event of a select option.

The function is:

<script type="text/javasript" src="jquery.min.js"></script>
<script type="text/javascript">
function desigchanged()
{
    
    $.get('jqueryphp.php?desig=wr',update);
}
function update(res)
{
    $('#inpt4').html(res);
}
</script>


<select id="inpt3" name ="designatn" onChange="desigchanged();">
            <option value="pm" selected>project manager</option>
            <option value="wr">worker</option>
            </select><BR><BR>
            <label><font id="fnm">Gender</font></label>
            <label><font id="fnm3">Male</font></label>
            <input name="gender" type="radio" id="inpt11" value="Male" />
            <label><font id="fnm4">Female</font></label>
            <input name="gender" type="radio" id="inpt22" value="Female" /><BR><BR>
            <label><font id="fnm">Works Under</font></label>
            <select name="wrkundr" id="inpt4">
            </select>

The jQuery file is included properly. Please someone help me.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
  • Possible duplicate of http://stackoverflow.com/questions/2075337/uncaught-referenceerror-is-not-defined – footy Jul 22 '12 at 09:05

2 Answers2

2

I suspect it's because of the typo:

type="text/javasript"

Note the missing "c" in "script". Browsers won't execute a script tag if its type attribute hasn't been defined correctly.

pimvdb
  • 151,816
  • 78
  • 307
  • 352
  • It's all the browsers according to my tests - if the type is defined but not correct, it won't be executed. This is good because you can place templates in `text/html` or whatever. Here's my test http://jsfiddle.net/s5rnv/ – Esailija Jul 22 '12 at 09:20
  • @Esailija: Thanks; I usually omit it altogether. – pimvdb Jul 22 '12 at 09:21
0

Edit:

But you may also be facing this problem (absolute/relative paths).

And

You also have a typo for javascript

Original:

have you done this

You should put the references to the jquery scripts first.

Or

This?

Maybe you are calling the ready function before the JQuery Javascript is included?

Community
  • 1
  • 1
footy
  • 5,803
  • 13
  • 48
  • 96
  • As can be seen in his snippet, he's including jQuery at the top and he's not using `ready`. – pimvdb Jul 22 '12 at 09:10
  • @pimvdb yeh, I just wanted to make sure that its the same way he is executing too. as some ppl cut/paste codes and make it cleaner here to make it look good :P ... btw I edited my post too – footy Jul 22 '12 at 09:17