Skip to content

Instantly share code, notes, and snippets.

@rushdimohamed09
Created January 18, 2017 15:08
Show Gist options
  • Save rushdimohamed09/411131978acf0905a0e9f2dfbcbf7b63 to your computer and use it in GitHub Desktop.
Save rushdimohamed09/411131978acf0905a0e9f2dfbcbf7b63 to your computer and use it in GitHub Desktop.
<?php
require_once ('../Connection/connection.php');
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
var i = 0;
function showSelected(val){
document.getElementById('selectedResult[]').innerHTML = val;
}
function myCreateFunction() {
var table = document.getElementById("myTable");
var row = table.insertRow(0);
var cell1 = row.insertCell(0);
var cell2 = row.insertCell(1);
cell1.innerHTML = "<select name='naa[]' id='stcard' onChange='showSelected(this.value)'> <?php $sql1 = 'SELECT * FROM mstock order by id asc'; $result1 = $conn->query($sql1); if ($result1->num_rows > 0) { while($row1 = $result1->fetch_assoc()) { echo '<option value='.$row1['card'].'>'.$row1['card'].'</option>'; } } ?> </select>";
cell2.innerHTML = "<div name='aaa[]' id='selectedResult[]'></div>";
i++;
}
function myDeleteFunction() {
document.getElementById("myTable").deleteRow(0);
}
</script>
</head>
<body>
<form method="post" action="222.php">
<p>Click the buttons to create and delete row(s) for the table.</p>
<input type="button" value="Add" onclick="myCreateFunction()" />
<input type="button" value="Del" onclick="myDeleteFunction()" />
<table id="myTable">
<tr>
<td>Row2 cell1</td>
<td>Row2 cell2</td>
</tr>
<tr>
<td>Row3 cell1</td>
<td>Row3 cell2</td>
</tr>
</table>
<br>
<input type="submit" name="submit" value="submit" />
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment