I need to create a page where I can choose a PLAN (or more) and a PLOT for each chosen plane. At the moment, when I make the foreground choice, it is interfering with the options available for the background choice, and this is not the desired behavior. I would like every% of plan% and its respective% share% to be independent of the other plans added.
Plan A:
Third Plot
Fifth Plot
Plan B:
First Plot
Second Plot
Third Plot
Fourth Plot
PlanJSCode
$(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);
};