Question

I'm working with Webworks for blackberry and i cant get to fire change on the device, in ripple it works like a charm but in the devices the change event doesn't fire... hope some1 can help me

HTML

<select name="motherCat" onchange="motherChanged(event)">
    <option value="0">option0</option>
    <option value="1">option1</option>
    <option value="2">option3</option>
</select>

<select id="subCategory">
    <option value="0">wait mother change to fill</option>
</select>

Javascript

function motherChanged(event){
    alert("motherChanged");
    var retCategory =subcategories[event.target.value];
    var fin = retCategory.length;
    var slCat = $('subCategory');
    slCat.length = 0;
    for(var i = 0;i<fin;i++){
        slCat.options.add(new Option(retCategory[i].text,retCategory[i].value));
    }
}
Was it helpful?

Solution

The problem is in how you've set the onchange property. event is undefined. Rather use something that will be defined:

<select name="motherCat" onchange="motherChanged(this)">

The this parameter will be the select element itself. Of course, you could also have a function that accepts no parameters, and then you can leave out the this.

OTHER TIPS

You could also use

<select name="motherCat" onchange="motherChanged">

and JavaScript should call the function with the event as a parameter.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top