I've created form with adding new form elements after pressing Add new (or whatver) button, followed by: http://phpmysqlmania.blogspot.com/p/dynamic-table-row-inserter.html
For example, I have:
<div id"row">
<select id="singleorfamily1" style="width: 180px;" name="singleorfamily" >
<option value="0">Select Single or Family</option>
<option value="single">Single</option>
<option value="family">Family</option>
</select>
<select id="selectedplan1" name="selectedplan" style="width: 110px;" >
<option value="0">Select Plan</option>
<option value="plan1">Plan1</option>
<option value="plan2">Plan2</option>
</select>
</div>
When I press Add new row, it add's new select element into row div:
<div id"row">
<select id="singleorfamily1" style="width: 180px;" name="singleorfamily1" >
<option value="0">Select Single or Family</option>
<option value="single">Single</option>
<option value="family">Family</option>
</select>
<select id="selectedplan1" name="selectedplan1" style="width: 110px;" >
<option value="0">Select Plan</option>
<option value="plan1">Plan1</option>
<option value="plan2">Plan2</option>
</select>
<select id="singleorfamily2" style="width: 180px;" name="singleorfamily2" >
<option value="0">Select Single or Family</option>
<option value="single">Single</option>
<option value="family">Family</option>
</select>
<select id="selectedplan2" name="selectedplan2" style="width: 110px;" >
<option value="0">Select Plan</option>
<option value="plan1">Plan1</option>
<option value="plan2">Plan2</option>
</select>
</div>
What I'm trying to make working (without success) and what I need to achieve - how to count selected Single and selected Family values in such case (select elements are dynamic - they can be 1 or 1000 or more). Singles: X, Families: Y. They should be counted after
jQuery('#singleorfamily'+i).change(function()
is made
I've tried "for" loop, "jQuery each"...but I can get it working just for 1 element, not for second, fifth, hundreths... I think I'm stucked how to correclty make looping... ;-O
Any suggestions how to correctly process any "thing" (calculation, event) withing dynamically created elements?
This what I've tried from suggestions: http://jsfiddle.net/AftpY/15/
But the problem is - volume is not updated, it is updated just when 1 select element is changed, but it does not updates "on fly"... And there You can see that there is also other select element...
Edited: Any ideas? I'm really stucked with this problem -> I can not understand (see Jsfiddle link): *)why count info is not refresed after each singleorfamily1 selection, but just when I changed first occurance of singleorfamily1 (can not see/find the problem in the code); *)how to count results of mixing selection values: how many singles from singleorfamily1 & plan1 from selectedplan1, how many family from selectedplan2 & plan2 from selectedplan2 etc...
TNX!