Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $a=0;
- while($row = mysql_fetch_assoc($execute)){
- $ID = $row['id'];
- $name[] = $row['names'];
- echo "<button name="btn$ID" class='btnName' onClick='showForm()'>$name[$a]</button>";
- $a++;
- }
- <div id="result" style="display: none;">
- //name from clicked buttons should be displayed here
- </div>
- ?>
- <script type="application/javascript">
- function showForm(){
- document.getElementById('result').style.display="block";
- }
- </script>
- function showForm(ev) {
- const name = ev.target.getAttribute("name");
- const result = document.getElementById('result')
- result.innerHTML = name;
- result.style.display = 'block';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement