Answer the question
In order to leave comments, you need to log in
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">
Answer the question
In order to leave comments, you need to log in
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
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 questionAsk a Question
731 491 924 answers to any question