I have a html file with the following code inside:
<input type="button" id="styles" value="Add More" onClick="addRow('data')" />
<form action="mail.php" method="post">
<table id="data"><tr><td>
<select name="selectorfirst" id="styles">
<option>Yellow</option>
<option>Green</option>
<option>Red</option>
</select>
</td>
<td>
<select name="selectorsecond" id="styles">
<option>375</option>
<option>1000</option>
<option>5000</option>
</select>
</td></tr></table>
<input id="styles" type="submit" value="Submit" />
</form>
I also have javascript which is copying this form by pressing a button (So I can have for example 4 different forms with the same options and ids).
function addRow(tableID) { var table = document.getElementById(tableID); }
I need to POST these values selected in form on the next page after pressing button. I tried the code below but it didnt work.
<? $selectorfirst = $_POST['selectorfirst'];
$selectorsecond = $_POST['selectorsecond']; ?>
<table id="data">
<?php foreach($selector as $key => $value) { ?>
<tr>
<td ><?php echo $a+1; ?></td>
<td>
<input type="text" id="styles" name="selectorfirst[$key]" value="<?php echo $selectorfirst[$key]; ?>">
</td>
<td>
<input type="text" id="styles" name="selectorsecond[$key]" value="<?php echo $selectorsecond[$key]; ?>">
</td>
</tr><?php } ?></table>