On Mar 4, 8:19 am, weheh <[email protected]> wrote:
> In particular, let's say I have two fields. The first field is
> fuel_type, which is from a set ['gasoline','diesel']. The second field
> is octane, which is from a set of either ['82','85','87','93'] or
> ['15','17','19','21','23','25']. Depending on which fuel type is
> selected, the select list for the octane rating will change.

This is a solution for jQuery:
$(function() {
    // When the Fuel_type changes:
        $("select[name='fuel_type']").change(function() {
        // What is the new type?
        fuel=$(this).val();
        if (fuel=="gasoline") {
            var octane=['82','85','87','93'];
        } else if (fuel=="diesel") {
            var octane=['15','17','19','21','23','25'];
        }
        // Refresh the resource lookuplist
        var options = '';
        //for (var i = 0; i < options_subtype.length; i++) {
        for(key in octane) {
            options += '<option value="' + octane[key] + '">' + octane
[key] + '</option>';
        }
        $("select[name='octane']").html(options);
        })
});
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to