Skip to content Skip to sidebar Skip to footer

Firefox Handles Xxx.submit(), Safari Doesn't ... What Can Be Done?

I'm trying to make a pull down menu post a form when the user selects (releases the mouse) on one of the options from the menu. This code works fine in FF but Safari, for some rea

Solution 1:

You should probably use the onchange event of the <select> instead (or as well).


Solution 2:

The code would be:

<form id="setlang_form" method="post" action="{% url django.views.i18n.set_language %}">
    <fieldset>
    <select name="language" onchange="formSubmit(this)">
    {% for lang in interface_languages %}
        <option value="{{ lang.code }}" {% ifequal lang.code LANGUAGE_CODE %}selected="selected"{% endifequal %}>{{ lang.name }}</option>
    {% endfor %}
    </select>
    </fieldset>
</form>

To get the value:

function formSubmit(theForm)
{
 .... theForm.options[theForm.selectedIndex].value
}

You can do it with jquery too:

$(document).ready(function() {
    $('#lang_submit').hide()
    $('#setlang_form select').change(function () { 
        ....     $("select option:selected").text() ....  
        } 
    });
});

Look here to know about change event with Jquery: http://docs.jquery.com/Events/change


Post a Comment for "Firefox Handles Xxx.submit(), Safari Doesn't ... What Can Be Done?"