Zdar
V kode je toto
<form name="raise" action="index.php?go=forms/frm_new_fill.php" method="POST">
<table id="tab_logic" style="background-color: #c0c0c0;text-align:center">
<thead>
<tr>
<th scope="col">None</th>
<th scope="col">Part number</th>
<th scope="col">Location</th>
<th scope="col">Quantity</th>
<th scope="col">Reason</th>
<th scope="col">Notes</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<div class="buttons">
<button type="submit" name="new" class="positive" onClick="submitLoader();">
<img src="Assets/images/apply2.png" width="16" height="16" alt=""/>
Submit
</button>
</div><div name="submitLoader" id="submitLoader" style="float:left"></div>
<div class="buttons">
<button type="reset" name="new" class="negative">
<img src="Assets/images/cross.png" width="16" height="16" alt=""/>
Reset
</button>
</div>
</form>
s scripte toto
<script>
$(document).ready(function() {
var i = 0;
var j = 0;
var code = '<?php give_me_reason_list(); ?>';
$("#add_row").click(function() {
$('tr').find('input').prop('disabled',true)
j = i;
$('#addr' + i).html(""+(j+1)+ "<td><input type='radio' name='plusminus" + j + "' id='plusminus" + j + "' value='1' onClick='activateReasons(" + j + ");' required/> +<BR/><input type='radio' name='plusminus" + j + "' id='plusminus" + j + "' value='2' onClick='activateReasons(" + j + ");'/> -<input type='hidden' name='value" + j + " id='value" + j + "' value=''><input type='hidden' name='curr" + j + "' id='curr" + j + "' value=''><input type='hidden' name='converted" + j + "' value=''></td><td style='text-align:left'><input type='text' name='part_no" + j + "' id='part_no" + j + "' value='' onBlur='getDescription(" + j + ");' required/><br/><div id='description" + j + "' style='text-align:left'></div><div id='price" + j + "' style='text-align:left'></div><div id='gbp_price" + j + "' style='text-align:left'></div></td><td><select name='location" + j + "' id='location" + j + "'><option value='S001'>Main Warehouse</option><option value='S002'>Moulding</option><option value='S003'>Production</option><option value='S090'>Finished Goods</option></select></td><td><input type='number' step='0.01' name='qty" + j + "' id='qty" + j + "' value='' size='5' onBlur='getPrice(" + j + ");'/></td>'<td><select id='reason" + j + "' name='reason" + j + "' disabled onChange='getCodes(" + j + ");'>"+ code + "</select><br/><div name='gl_cc" + j + "' id='gl_cc" + j + "' style='text-align:left'>You must choose + or - to be able to select reason.</div></td><td><textarea name='notes" + j + "' rows=3 cols=20></textarea></td>" );
j++
$('#tab_logic').append('<tr id="addr' + (i + 1) + '"></tr>');
document.getElementById("item_count").value= i;
i++;
});
});
</script>
Ak odoslem len jednu polozku je to fajn. Ak ich odoslem 2 alebo viac take mi to hadze chybu otice: Undefined index: part_no1 in
kod ktory to spracovava
for ($j = 1; $j <= $i; $j++) {
$clock_no = $_POST['clock_no'];
$part_no = strtoupper($_POST['part_no' . $j . '']);
echo $part_no;
$qty = $_POST['qty' . $j . ''];
$location = trim($_POST['location' . $j . '']);
$reason = $_POST['reason' . $j . ''];
$notes = $_POST['notes' . $j . ''];
$notes = str_replace("'", "''", $notes);
if (isset($_POST['gl_account' . $j . ''])) {
$gl_account = $_POST['gl_account' . $j . ''];
} else {
$gl_account = '';
}
if (isset($_POST['cost_centre' . $j . ''])) {
$cost_centre = $_POST['cost_centre' . $j . ''];
} else {
$cost_centre = '';
}
čo s tým? Preco sa to deje?