Reputation: 347
I have the following code in my html page:
$("#rulecondition").change(function () {
var txt = $(this).val();
alert(txt);
switch (txt)
{
case 'Always use this rule':
$('#callerid_condition_container').hide();
$('#time_condition_container').hide();
break;
case 'Depends on who is calling':
$('#callerid_condition_container').fadein();
$('#time_condition_container').hide();
break;
case 'Depends on the time of day':
$('#time_condition_container').fadein();
break;
default:
}
});
When I load the page, I'm getting a script error that says:
SCRIPT5009: '​' is undefined
testpage, line 262 character 6
Here's what the rendered code looks like:
$("#rulecondition").change(function () {
var txt = $(this).val();
alert(txt);
switch (txt)
{
case 'Always use this rule':
$('#callerid_condition_container').hide();
$('#time_condition_container').hide();
break;
case 'Depends on who is calling':
$('#callerid_condition_container').fadein();
$('#time_condition_container').hide();
break;
case 'Depends on the time of day':
$('#time_condition_container').fadein();
break;
default:
}
});â
As you can see, there's some funky character after the closing bracket for my jQuery method. I'm not sure how that's created or how to get rid of it! The other question I have is why the alert statement only shows the first word in each option? So for example, if the user selects "Always use this rule", the alert will show "Always".
Upvotes: 1
Views: 130
Reputation: 10219
You got 2 problems
Open your file in an editor like notepad++ and set it to display "all characters" (white spaces and all) then delete those "invisible" characters after your closing bracket.
Also, check if you're in UTF-8 and put it in UTF-8 without BOM. (EDIT : use "convert" instead of "encode")
As https://stackoverflow.com/a/4901138/460368 statued, option's value attribute can't be anything. I guess you shouldn't use space in it.
Upvotes: 2
Reputation: 10040
Can you give the contents of rulecondition.
The first thing that comes to mind with your funky character is a ms character. Did you copy and paste anything?-Try rewriting it from scratch.
Upvotes: 0