views:

46

answers:

2

I have this form in a Django application In Firefox it works as charm, and in Chrome/IE6 this won't do the post operation needed Any ideas why ?

<form action="/lang/i18n/setlang/" method="post">
<input name="next" type="hidden"  />

<input name="language" type="image" value="ar" src="/flags/flag_ar.jpg" onclick="this.form.submit()" title="Arabic" />

<input name="language" type="image" value="fr" src="/flags/flag_fr.jpg" onclick="this.form.submit()" title="French" />

<input name="language" type="image" value="en" src="/flags/flag_en.jpg" onclick="this.form.submit()" title="English" />

<input name="language" type="image" value="es" src="/flags/flag_es.jpg" onclick="this.form.submit()" title="Spanish" />

<input name="language" type="image" value="de" src="/flags/flag_de.jpg" onclick="this.form.submit()" title="German" />

<input name="language" type="image" value="pl" src="/flags/flag_pl.jpg" onclick="this.form.submit()" title="Polish" />

<input name="language" type="image" value="ro" src="/flags/flag_ro.jpg" onclick="this.form.submit()" title="Romanian" />

</form>

Edit: Thanks Bryan and lock, it did solve my problem.

too bad I wasn't reading it before I wrote this long and ugly fix:

{% load i18n %}
<form name="lang" action="{{ i18n_prefix }}setlang/" method="post">{% csrf_token %}
<input name="next" type="hidden" {% if redirect %}value="{{ redirect }}"{% endif %} />
<input name="language" type="hidden" >
{% for lang in LANGUAGES %}
<a href="#" onclick="javascript: document.forms['lang'].language.value ='{{ lang.0 }}'; document.forms['lang'].submit();"><img src="{{ flags_url }}flag_{{ lang.0 }}.jpg" title="{% trans lang.1 %}"></a>
{% endfor %}
</form>
+2  A: 

I'm pretty sure you don't need the onclick="this.form.submit()" attribute on an <input type="image">. They should be clickable by default.

Bryan Ross
removing that onclick attribute would solve your problem
lock
A: 

in plain javascript -> onclick="this.parent.parent.submit()"

jQuery -> onclick="jQuery(this).parents('form').submit()"

dux