I am trying to set up as a form, with several options select
, where an age range is selected, depending on the selected range, it will grant a value
which would be the amount for the age range.
Then two options would come, yes and no , of which if you choose yes , it value
is 24 if it is not then it is 0.
For the first I manage to create the select
and its options, I give them their value
, but when I want to proceed with the addition, I don't know how to write it.
In the case of the yes/no options , I thought of using booleans, but as I indicated I am new, I understand the theory but I lack practice, I appreciate your help. This is just a personal project to streamline a part of my work.
<pre>
<h2>Seleccione el Rango de Edad:</h2>
<select id="diezk" onchange="select()">
<option value="180">4-18</option>
<option value="230">19-22</option>
<option value="360">23-29</option>
<option value="420">30-37</option>
</select>
<h2>Desea usar </h2>
<select id="asit" onchange="select()">
<option value="24">Si</option>
<option value="0">No</option>
</select>
<h2>Desea usar </h2>
<select id="fun" onchange="select()">
<option value="24">Si</option>
<option value="0">No</option>
</select>
</pre>
An option that I propose is that
select
you put the same class in all of them and injQuery
you could obtain thevalue
selected ones within a cycleeach
, the sum is obtained and the result is passed to where you need it. In my case in ainput
.Another thing to keep in mind is to add a
option
withvalue
0 and with the attributehidden
so that it is hidden once another option is selected. This is to avoid errors in calculating the total.