我刚学,请教我怎么取值 from <input type="radio" />, in input'e typetext一个字段,y radio- 2,怎么取到我看不懂的checkbox的值。
$(function() {
// Кнопка сохранить
$(".save").click(function() {
var A = $(this).parent().parent();
var X = A.attr("id");
var d = X.split("formbox"); // Определяем id : formbox
var id = d[1];
var Z = $("#" + X + " input.name").val();
var S = $("#" + X + " input.am").val();
var I = $("#" + X + " input.tp").val(); //Вот тут я похоже
var Y = $("#" + X + " input.noind").val(); //не правильно получаю данные
console.log("var S " + S); //Ok
console.log("var Z " + Z); //Ok
console.log("var Y " + Y); //Undefined
console.log("var I " + I); //Undefined
})
})
<form method="post" name="form811">
<label for="name">Название</label>
<input id="name811" type="text" value="" name="name" class="name" />
<label for="am">Сумма</label>
<input type="text" value="0" name="am" class="am" />
<span class="label">Индекс:</span>
<input id="index811" type="radio" name="noind" value="0" checked="checked" />
<label for="index811">index</label>
<input id="noindex811" type="radio" name="noind" value="1" />
<label for="noindex811">no index</label>
<span class="label">Тип:</span>
<input id="photo811" type="radio" name="tp" value="0" checked="checked" />
<label for="photo811">фото</label>
<input id="price811" type="radio" name="tp" value="1" />
<label for="price811">для прайса</label>
<input type="hidden" name="mode" value="alt_edit" />
<input type="submit" value="Сохранить" class="save" />
</form>
像这样决定