0
I need to create a page where I can choose a PLAN (or more) and a INSTALLMENT for each chosen plan. At the moment, when I choose the foreground, it is interfering with the options available to choose the background, and that is not the desired behavior. I would like each dropdown
plan and its respective dropdown
share are independent of other added plans.
Plan A:
Third Installment
Fifth Plot
Plan B:
First Installment
Second Installment
Third Installment
Fourth Installment
JS Code of the Plan
$(document).ready(function()
{
$(".plano").change(function()
{
var id=$(this).val();
var dataString = 'id='+ id;
$.ajax
({
type: "POST",
url: "get_plano2.php",
data: dataString,
cache: false,
success: function(html)
{
$(".parcela").html(html);
}
});
});
});
Html code
<td>
<select name="usuarios[0][plano]" class="plano">
<option selected="selected">Selecione</option>
<?php
$stmt = $DB->prepare("SELECT * FROM plano");
$stmt->execute();
while($row=$stmt->fetch(PDO::FETCH_ASSOC))
{
?>
<option value="<?php echo $row['id_plano']; ?>"><?php echo $row['nome_plano']; ?></option>
<?php
}
?>
</select>
</td>
<td>
<select name="usuarios[0][parcela]" class="parcela">
<option selected="selected">Selecione</option>
</select>
</td>
<td>
<input type="text" name="usuarios[0][comissao_vendedor]" id="valor_total_saude_vendedor" class="calcular" placeholder="R$" onkeypress="mascara(this,mreais)" onkeyup="calcular()">
</td>
Javascript code
var AddTableRow = function(el) {
var tbody = $(el).closest('table').find('tbody');
var row = tbody.find('tr:last').clone();
var name = row.find('.calcular').attr('name');
var index = parseInt(name.match(/usuarios\[(\d+)\]\[comissao_vendedor\]/)[1], 10) + 1;
row.find('[name^="usuarios["]').each(function() {
if (this.name) {
this.name = this.name.replace(/^usuarios\[\d+\]/, "usuarios[" + index + "]");
}
});
tbody.append(row);
};