Reputation: 18118
Hi i get a error below:
05-31 11:17:20.427: D/CordovaLog(20889): Uncaught ReferenceError: hello is not defined
on my html i have embeded the following to pass the toggleswitch element to my javascript function
<select name="toggleswitch1" id="toggleswitch1" data-theme="" data-role="slider"
data-mini="true" onchange="hello(document.getElementById('toggleswitch1'))">
here is my javascript
<script>
function hello(toggle)
{
var e = toggle;
var value = e.options[e.selectedIndex].value;
if value == "yes"
{
//do something
}
}
</script>
what am i missing?
Upvotes: 0
Views: 139
Reputation: 10075
Please try this:
<script>
function hello(toggle)
{
var e = toggle;
var value = e.options[e.selectedIndex].value;
if(value == "yes")
{
//do something
}
}
</script>
You forgot the (
and )
on the if:
Upvotes: 1
Reputation: 5243
You have an error in your script :
<script>
function hello(toggle)
{
var e = toggle;
var value = e.options[e.selectedIndex].value;
if (value == "yes")
{
//do something
}
}
</script>
Upvotes: 3