У меня есть форма, содержащая переключатели. Они называются option1, option2 и option3. Каждая из этих радиокнопок имеет 3 разных значения потенциала.
Мне нужно отобразить текущее «проверенное» значение под формой. Я следил за руководством по jquery и сильно запутался.
<script>
function displayVals() {
var opt1 = $('input:radio[name=option1]:checked').val() || [];
var opt2 = $('input:radio[name=option2]:checked').val() || [];
var opt3 = $('input:radio[name=option3]:checked').val() || [];
$("p").html("First item is " + opt1.join(", ") + " the second is " + opt2.join(", ") + " and third is " + opt3.join(", ") + ".");
}
$("input").change(displayVals);
displayVals();
However, nothing displays below the form. For example, option1 could be either White, Red or Black. If they check black, I need it to say "First item is black the second is whatever and the third is whatever." Below the form updating each time one of the values changes.
join
. - person Prinzhorn   schedule 22.09.2012