Estimados necesito su ayuda, como podría realizar operaciones con :
<span>
y <select> <option>
con javascript
Mi código.
<table border="1">
<thead>
<tr>
<th>Categoria</th>
<th>Precio</th>
<th>cantidad Habitacion</th>
</tr>
</thead>
<tbody>
<tr>
<td>Matrimonial</td>
<td><span id="precio_1">200.00</span></td>
<td>
<select id="reserva_1" name="reserva_1">
<option id="matrimonial_0" value="0">0</option>
<option id="matrimonial_1" value="1">1-habitacion</option>
<option id="matrimonial_2" value="2">2-habitaciones</option>
</select>
</td>
</tr>
<tr>
<td>Simple</td>
<td><span id="precio_2">120.00</span></td>
<td>
<select id="reserva_2" name="reserva_2">
<option id="simple_0" value="0">0</option>
<option id="simple_1" value="1">1-habitacion</option>
<option id="simple_2" value="2">2-habitaciones</option>
<option id="simple_3" value="3">3-habitaciones</option>
</select>
</td>
</tr>
<tr>
<td>Doble</td>
<td><span id="precio_3">200.00</span></td>
<td>
<select id="reserva_3" name="reserva_3">
<option id="doble_0" value="0">0</option>
<option id="doble_1" value="1">1-habitacion</option>
<option id="doble_2" value="2">2-habitaciones</option>
<option id="doble_3" value="3">3-habitaciones</option>
<option id="doble_4" value="4">4-habitaciones</option>
</select>
</td>
</tr>
</tbody>
</table>
<button type="button" id="calcular" name="button">Calcular</button> Total de reservas : <input type="text" name="resultado" id="resultado" disabled="" value="">
Esta tabla
es dinámica, el javascript
tiene que poder realizar las operaciones,cuando haya solo un tipo de habitación o mas, las filas no son estáticas, (en mi bucle en php pongo un id diferente en las etiquetas span
y select
y sus option
respectivos, con eso deseo trabajar las operaciones)
Como debe de calcular
el option
se multiplica con span
(por fila)
y al final realizaría la sumatoria.
mejor dicho precio
* cantidad habitacion
y su total.
Poniendo el resultado en el input id='resultado'