I've two forms on the same page: the first, on submit, will call himself and if some parameters are set it will echo the second with a table with each row a radio box with different values and, at the bottom, a value inserted with innerHTML
in a <td>
. At the end of the page will be generated also another button that will send to another PHP page responsible to insert the data on a DB.
The first form is closed after the first button. The second one is opened dynamically with the other dynamic code after the first button and closed dynamically at the bottom of the page after the second button.
What I'm trying to do is to pass any inserted or generated field (or checkbox) to the last PHP (the one which insert the data), but using the method described looks like it doesn't work - if i try to get the POST
parameter on the last PHP it simply doesn't print anything. If i use another form that starts at the beginning and finishes at the end of the page doesn't work either.
The HTMLcode
<!DOCTYPE html>
<html lang="it">
<head>
<meta charset="utf-8" />
<title>Inserimento Prestazioni</title>
<link rel="stylesheet" href="css/bootstrap.css" type="text/css" />
<link rel="stylesheet" href="css/style.css" type="text/css" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/bootstrap.js"></script>
<script type='text/javascript'>
function ControllaCodice(c){
if(c.checked && document.getElementById('importoselezionato').innerHTML!=0) {
var importoselezionato = Number(document.getElementById('importoselezionato').innerHTML.replace('€','')) + Number(c.value);
document.getElementById('importoselezionato').innerHTML=importoselezionato + "€";
}else if (c.checked){
var importoselezionato= c.value;
document.getElementById('importoselezionato').innerHTML=importoselezionato + "€";
}else if(c.checked== false && document.getElementById('importoselezionato').innerHTML!=0){
var importoselezionato= Number(document.getElementById('importoselezionato').innerHTML.replace('€','')) - Number(c.value);
document.getElementById('importoselezionato').innerHTML=importoselezionato + "€";
}else if(c.checked == false){
var importoselezionato= c.value;
document.getElementById('importoselezionato').innerHTML=importoselezionato + "€";
}
}
</script>
</head>
<body>
<!-- INIZIO pagina reale-->
<!-- INIZIO menù-->
<div class="container" style="width:100%;">
<nav class="navbar navbar-default" role="navigation">
<!-- Raggruppa menù -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<!-- visualizzo raggruppamento -->
<div class="collapse navbar-collapse navbar-ex1-collapse">
<ul class="nav navbar-nav">
<li><a href="index1.php"><strong>Inserisci Anagrafiche</strong></a></li>
<li class="active"><a href="#"><strong>Inserisci Prestazioni</strong></a></li>
<li><a href="index3.php"><strong>Inserisci Voucher</strong></a></li>
<li><a href="index4.php"><strong>Assegna Voucher</strong></a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><strong>Interroga Database</strong><strong class="caret"></strong></a>
<ul class="dropdown-menu">
<li><a href="#">Interroga Database</a></li>
<li><a href="#">Esporta Dati</a></li>
</ul>
</li>
</ul>
</div>
</nav>
</div> <!-- FINE menù-->
<center>
<div style="padding-top:5%;">
<h1>Inserimento Prestazioni</h1>
</center>
</div><br/>
<center>
<div style="margin-top:5%;" class="row">
<form name="caricaprestazione" method="post" action="index2.php" class="form-inline" id="carica">
<div class="form-group" style="width:23%;">
<fieldset class="form-group">
<label for="persona">Persona *</label>
<select class="form-control" id="persona" name="persona" style="width:100%;">
<option value='15'>Giovanna Serani</option><option value='11'>angelo brittone</option><option value='10'>fhlksih olhiswkjiefnwsosidfh</option><option value='14'>Filippo Corsari</option><option value='16'>Franca Giovinelli</option><option value='15'>Giovanna Serani</option><option value='17'>Giulia Tressani</option><option value='12'>Martina Schiavon</option><option value='9'>pippo pappo</option><option value='13'>Roberto Casalecci</option>
</select>
</fieldset>
</div>
<div class="form-group" style="width:23%;">
<fieldset class="form-group">
<label for="datainizio">Inizio Prestazione *</label>
<input type="date" class="form-control" id="datainizio" name="datainizio" style="width:100%;" value="2016-07-02">
</fieldset>
</div>
<div class="form-group" style="width:23%;">
<fieldset class="form-group">
<label for="datafine">Fine Prestazione *</label>
<input type="date" class="form-control" id="datafine" name="datafine" style="width:100%;" value="2016-07-14">
</fieldset>
</div>
<div class="form-group" style="width:23%;">
<fieldset class="form-group">
<label for="importo">Importo Lordo*</label>
<div class="input-group">
<input type="number" class="form-control" id="importolordo" name="importolordo" placeholder="Importo Lordo" style="width:100%;" value="30">
<div class="input-group-addon" style="width:10%;">€</div>
</div>
</fieldset>
</div><br/><br/><br/>
<div class="form-group" style="width:100%;">
<fieldset class="form-group">
<label for="note">Note</label>
<textarea class="form-control" id="note" placeholder="Note" name="note" style="width:100%;"></textarea>
</fieldset>
</div>
<div style="margin-top:70px;">
<button type="submit" class="btn btn-primary" onclick="document.getElementById('carica').submit()">Assegna Voucher</button>
</div>
</div>
<form name='inserisciprestazione' method='post' action='php/inserisci_prestazione.php' class='form-inline' id='inserisci'><table class='table table-striped' style='margin-top:70px; width: 60%;'>
<tr>
<th>#</th>
<th>Codice di controllo</th>
<th>Numero</th>
<th>Data Emissione</th>
<th>Data Registrazione</th>
<th>Valore Lordo</th>
</tr><tr>
<td id=0><input type='checkbox' value='0' onchange='ControllaCodice(this)' id='0'></td>
<td>987978456</td>
<td>0</td>
<td>26/03/2016</td>
<td>18/07/2016</td>
<td>0</td>
</tr><tr>
<td id=0><input type='checkbox' value='0' onchange='ControllaCodice(this)' id='0'></td>
<td>987978456</td>
<td>0</td>
<td>26/03/2016</td>
<td>18/07/2016</td>
<td>0</td>
</tr><tr>
<td id=0><input type='checkbox' value='0' onchange='ControllaCodice(this)' id='0'></td>
<td>987978456</td>
<td>0</td>
<td>26/03/2016</td>
<td>18/07/2016</td>
<td>0</td>
</tr><tr>
<td id=0><input type='checkbox' value='0' onchange='ControllaCodice(this)' id='0'></td>
<td>987978456</td>
<td>0</td>
<td>26/03/2016</td>
<td>18/07/2016</td>
<td>0</td>
</tr><tr>
<td id=37561><input type='checkbox' value='10' onchange='ControllaCodice(this)' id='37561'></td>
<td>98746411</td>
<td>37561</td>
<td>07/05/2016</td>
<td>18/07/2016</td>
<td>10</td>
</tr><tr>
<td id=37562><input type='checkbox' value='10' onchange='ControllaCodice(this)' id='37562'></td>
<td>98746411</td>
<td>37562</td>
<td>07/05/2016</td>
<td>18/07/2016</td>
<td>10</td>
</tr><tr>
<td id=37563><input type='checkbox' value='10' onchange='ControllaCodice(this)' id='37563'></td>
<td>98746411</td>
<td>37563</td>
<td>07/05/2016</td>
<td>18/07/2016</td>
<td>10</td>
</tr><tr>
<td id=37564><input type='checkbox' value='10' onchange='ControllaCodice(this)' id='37564'></td>
<td>98746411</td>
<td>37564</td>
<td>07/05/2016</td>
<td>18/07/2016</td>
<td>10</td>
</tr><tr>
<td id=37565><input type='checkbox' value='10' onchange='ControllaCodice(this)' id='37565'></td>
<td>98746411</td>
<td>37565</td>
<td>07/05/2016</td>
<td>18/07/2016</td>
<td>10</td>
</tr><tr>
<td id=37566><input type='checkbox' value='10' onchange='ControllaCodice(this)' id='37566'></td>
<td>98746411</td>
<td>37566</td>
<td>07/05/2016</td>
<td>18/07/2016</td>
<td>10</td>
</tr><tr>
<td id=37567><input type='checkbox' value='10' onchange='ControllaCodice(this)' id='37567'></td>
<td>98746411</td>
<td>37567</td>
<td>07/05/2016</td>
<td>18/07/2016</td>
<td>10</td>
</tr><tr>
<td id=37568><input type='checkbox' value='10' onchange='ControllaCodice(this)' id='37568'></td>
<td>98746411</td>
<td>37568</td>
<td>07/05/2016</td>
<td>18/07/2016</td>
<td>10</td>
</tr><tr>
<td id=37569><input type='checkbox' value='10' onchange='ControllaCodice(this)' id='37569'></td>
<td>98746411</td>
<td>37569</td>
<td>07/05/2016</td>
<td>18/07/2016</td>
<td>10</td>
</tr></table>
<h4 style='margin-top:2%;'>Riepilogo</h4><br/>
<table style='width:100%;' class='table table-striped'>
<tr>
<th>Persona</th>
<th>Data Inizio Prestazione</th>
<th>Data Fine Prestazione</th>
<th>Importo Lordo Prestazione</th>
<th>Importo Lordo Selezionato</th>
</tr>
<tr>
<td>Giovanna Serani</td>
<td>02/07/2016</td>
<td>14/07/2016</td>
<td>30 €</td>
<td id='importoselezionato'></td>
<tr/>
</table><div style='margin-top:70px;'>
<button type='submit' class='btn btn-primary' onclick='document.getElementById('inserisci').submit()'>Registra</button>
</div>
</form> </form>
</center>
</div>
</div>
</body> <!-- FINE pagina reale-->
</html>