Я хочу идентифицировать (предупредить) каждое значение выбора / опции в каждой группе.
Но мне нужен толчок ...
<script src="jquery.mobile/jquery.js"></script>
<div id="groupA" class="preGroups">
<div id="section-A1">
<input name="SRPR1" type="text">
<select name='ACTC' id='preAction' >
<option value='007'>Stolen</option>
<option value='008'>Tampered</option>
</select>
</div>
<div id="section-A2">
<input name="SRPR1" type="text">
<select name='ACTC' id='preAction' >
<option value='007'>Stolen</option>
<option value='008'>Tampered</option>
</select>
</div>
</div>
<div id="groupB" class="preGroups">
<div id="section-B1">
<input name="SRPR1" type="text">
<select name='ACTC' id='preAction' >
<option value='007'>Stolen</option>
<option value='008'>Tampered</option>
</select>
</div>
<div id="section-B2">
<input name="SRPR1" type="text">
<select name='ACTC' id='preAction' >
<option value='007'>Stolen</option>
<option value='008'>Tampered</option>
</select>
</div>
<script>
$(document).ready(function()
{
// iterate through each group in groups
groups = $('div[id^="group"]');
$.each(groups, function(key, group) {
fnValidateGroup($(group));
});
// validation for reason codes in a specific Group
function fnValidateGroup(currentGroup){
selects = $(currentGroup).find('select[name="ACTC"]');
$.each(selects, function(key, activity) {
// show me activity seelctec in each case
alert($(activity).val) ;
});
}
});
</script>
* редактировать *
вывод должен выглядеть так:
new Group
007
008
new Group
007
007
* редактировать *
Вот ответ, к которому я пришел с вашей помощью ...
$(document).ready(function()
{
// iterate through each group in groups
groups = $('div[id^="group"]');
$.each(groups, function() {
console.log("New Group");
fnValidateGroup(this);
});
// validation for reason codes in a specific Group
function fnValidateGroup(currentGroup){
selects = $(currentGroup).find('select[name="ACTC"]');
$.each(selects, function(key, activity) {
// show me activity seelctec in each case
console.log(($(activity)).val());
});
}
});