Browse Source

added button to add a random title to titles page

main
Simon Bowie 2 years ago
parent
commit
36cca1baa2
1 changed files with 21 additions and 0 deletions
  1. +21
    -0
      site/public/titles.php

+ 21
- 0
site/public/titles.php View File



$core = 'all'; $core = 'all';
$random_titles = ten_random_titles($core); $random_titles = ten_random_titles($core);
$additional_titles = ten_random_titles($core);


?> ?>


<div class="container"> <div class="container">


<button class="float-end btn btn-danger" onclick="removeRandomTitle()">-</button> <button class="float-end btn btn-danger" onclick="removeRandomTitle()">-</button>
<button class="float-end btn btn-danger" onclick="addRandomTitle()">+</button>

<?php <?php


foreach ($random_titles as $record_array): foreach ($random_titles as $record_array):
<?php <?php
endforeach; endforeach;
?> ?>
<span class="add_title">
</span>

</div> </div>
<script> <script>

var titles = <?php echo json_encode($additional_titles); ?>;

x = 0;

function addRandomTitle(){
var record_array = titles[x];
let title = "";
for (const id in record_array) {
title += record_array[id];
document.querySelector('.container').innerHTML += "<a href='id_search.php?id=" + id + "&core=all'><span class='title'>" + title + "</span></a><br><br><hr>";
x++;
}
}

function removeRandomTitle() { function removeRandomTitle() {
var elts = document.getElementsByClassName("title"); var elts = document.getElementsByClassName("title");
var RandomSpan = elts[Math.floor(Math.random() * elts.length)]; var RandomSpan = elts[Math.floor(Math.random() * elts.length)];

Loading…
Cancel
Save