Friend, the most correct way to do PHP would be by using the input value as a Array
.
I mean. Instead of doing this:
var add = 1;
function add_fields() {
var d = document.getElementById("content");
add++;
d.innerHTML += "<br /><label class='tooltips'>A ser excluído "+add+": <input type='text' name='solicitacao"+add+"'/></label>";
}
You should do this:
var add = 1;
function add_fields() {
var d = document.getElementById("content");
add++;
d.innerHTML += "<br /><label class='tooltips'>A ser excluído "+add+": <input type='text' name='solicitacao[]'/></label>";
}
Simply put: we replace the "solicitacao" + add
for "solicitacao[]"
.
By doing this, PHP will access the value of solicitacao[]
through $_POST['solicitacao']
, and this will return a Array
with all data entered.
Thus, such an operation becomes more dynamic, dispensing with the use of counters to do so.
Remembering that one should declare these inputs within the form (<form>
), in order to submit the values.
Good, vlw. The code is right. That was just a clipping.
– Jobson Robson