form not working properly? : So I'm trying to make a website with offers with php. I have a function that i use in a for loop with and the results from the database are passed in the function. The code is like this: 

<?php 
function table_values($row0,$row1,$row2,$row3,$row4,$row5){
				
				$table_element = "<div id=\"$row0\" class='tab'>
												<div class='tab-header'>";
					switch ($row1) {
						case "Tiscali":
							$img = "<img src='images/tiscali.png' alt='Tiscali' />";
							break;
						case "Infostrada":
							$img = "<img src='images/infostrada.png' alt='Infostrada' />";
							break;
						case "Fastweb":
							$img = "<img src='images/fastweb.png' alt='Fastweb' />";
							break;
						case "TIM":
							$img = "<img src='images/telecom-italia.png' alt='TIM' />";
							break;
					}
			$table_element = $table_element . " $img <span>$row2</span></div>
												<div class='block'>
													<div class='first-set-block'>
														<span class='s2'>Download</span><br /><span class='s3'>$row3 Mbps</span>
													</div>
													<div class='first-set-block'>
														<span class='s4'>ATTIVAZIONE</span><br /><span class='s5'>GRATUITA</span>
													</div>
												</div>
												<div class='block'>
													<div class='block-header'>
														Costo standard
													</div>
													<div class='block-describe-standard'>
														<span class='s6'>&#8364; $row4</span>
													</div>
												</div>
												<div class='block'>
													<div class='block-header'>
														Promozione
													</div>
													<div class='block-describe-promozione'>
														<span class='s7'>&#8364; $row5</span>
													</div>
												</div>
												<div class='block'>
													<div class='block-header-last'>
														Costo 1 anno
													</div>
													<div class='block-describe-costo'>
														<span class='desc1'>&#8364; 21</span>
														<span class='desc2'>.32<br />&#8364;/mese</span>
														<button class='ordina-offerta'>Ordina</button>
													</div>
												
												</div>
											   </div>
											   <div class='black'>
													</div>
											   <div class='popup' id='pop".$row0."'>
											   <form method='post' action='off.php'>
													<span class='close'>&times;</span>
													
													
													<table width='100%' style='text-align: center;'>
														<tr>
															<td>Nome: </td><td><input type='text' name='nome' /></td>
														</tr>
														<tr>
															<td>Cognome: </td><td><input type='text' name='cognome' /></td>
														</tr>
														 <tr>
															<td>id: </td><td><input type='text' name='id' value=\"$row0\" /></td>
														</tr>
														<tr>
															<td colspan='2'><input type='submit' value='Carica' class='carica' /></td>
														</tr>
													</table> 
												</form>
												</div>";
																
				
				return $table_element;
			}
?>
but for one reason i want that the div black and div popup to be child of the div class tab but when i change the code from that above to this the submit button doesn't work.

<?php 
function table_values($row0,$row1,$row2,$row3,$row4,$row5){
				
				$table_element = "<div id=\"$row0\" class='tab'>
												<div class='tab-header'>";
					switch ($row1) {
						case "Tiscali":
							$img = "<img src='images/tiscali.png' alt='Tiscali' />";
							break;
						case "Infostrada":
							$img = "<img src='images/infostrada.png' alt='Infostrada' />";
							break;
						case "Fastweb":
							$img = "<img src='images/fastweb.png' alt='Fastweb' />";
							break;
						case "TIM":
							$img = "<img src='images/telecom-italia.png' alt='TIM' />";
							break;
					}
			$table_element = $table_element . " $img <span>$row2</span></div>
												<div class='block'>
													<div class='first-set-block'>
														<span class='s2'>Download</span><br /><span class='s3'>$row3 Mbps</span>
													</div>
													<div class='first-set-block'>
														<span class='s4'>ATTIVAZIONE</span><br /><span class='s5'>GRATUITA</span>
													</div>
												</div>
												<div class='block'>
													<div class='block-header'>
														Costo standard
													</div>
													<div class='block-describe-standard'>
														<span class='s6'>&#8364; $row4</span>
													</div>
												</div>
												<div class='block'>
													<div class='block-header'>
														Promozione
													</div>
													<div class='block-describe-promozione'>
														<span class='s7'>&#8364; $row5</span>
													</div>
												</div>
												<div class='block'>
													<div class='block-header-last'>
														Costo 1 anno
													</div>
													<div class='block-describe-costo'>
														<span class='desc1'>&#8364; 21</span>
														<span class='desc2'>.32<br />&#8364;/mese</span>
														<button class='ordina-offerta'>Ordina</button>
													</div>
												
												</div>
											  
											   <div class='black'>
													</div>
											   <div class='popup' id='pop".$row0."'>
											   <form method='post' action='off.php'>
													<span class='close'>&times;</span>
													
													
													<table width='100%' style='text-align: center;'>
														<tr>
															<td>Nome: </td><td><input type='text' name='nome' /></td>
														</tr>
														<tr>
															<td>Cognome: </td><td><input type='text' name='cognome' /></td>
														</tr>
														 <tr>
															<td>id: </td><td><input type='text' name='id' value=\"$row0\" /></td>
														</tr>
														<tr>
															<td colspan='2'><input type='submit' value='Carica' class='carica' /></td>
														</tr>
													</table> 
												</form>
												</div></div>";
																
				
				return $table_element;
			}
?>

does any body know why. I need to make them children of tab class for jquery reasons to use the parent() function.. Thanks in advanced, hope that i was clear.