K
K
kschingiz2014-11-26 22:54:40
MODX
kschingiz, 2014-11-26 22:54:40

How to send the value of the clicked one from several inputs with the same name?

Situation: I put a language switch on the site like this:

<input src="http://nla.selective.kz/image/en.png" alt="Select language" title="Select language" name="yams_new_lang" class="yams_lang_en" xml:lang="en" dir="ltr" value="en" lang="en" type="image">
<input src="http://nla.selective.kz/image/ru.png" alt="Выберите язык" title="Выберите язык" name="yams_new_lang" class="yams_lang_ru" xml:lang="ru" dir="ltr" value="ru" lang="ru" type="image">
<input src="http://nla.selective.kz/image/kz.png" alt="Выберите язык" title="Выберите язык" name="yams_new_lang" class="yams_lang_kz" xml:lang="kz" dir="ltr" value="kz" lang="kz" type="image">

This thing works on MODX EVO, under the YAMS extension, when a button is pressed in chrome, the one that was clicked is sent, and the language switches normally, but in FF it does not switch, since it sends everything, and the site receives yams_new_lang as an empty value.
Question: How can I send the value of the clicked input from multiple inputs with the same name?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Aksentiev, 2014-11-26
@Sanasol

type="image" works like submit, so what is clicked should be sent accordingly. But of course it's better to do something differently with a link or something like that

K
Keyn Din, 2014-11-26
@Lure_of_Chaos

according to the w3c specification, only the name-value of the button (image - the same submit) that was clicked, but not others, is sent to the server.
by the way, unselected checkbox elements are also not sent (fact for better understanding).
and yes, DO NOT set lang, because it is used at a certain localization.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question