JavaScript HTML Form Number Type Unique User Input with Javascript and PHP html form number input,html form number only,html form

This question is a follow up to what I previously asked (HTML Form Number Type Unique User Input) but now I'm making the form more dynamic.

The following form asks users to list there 3 favorite genres of music:

<form id="genre" name="genre" method="post" action="musicsell.php">
  <input type="checkbox" name="genre[]" id="Rap" value="Rap"/>Rap<br />
  <input type="checkbox" name="genre[]" id="HipHop" value="HipHop"/>HipHop<br />
  <input type="checkbox" name="genre[]" id="RnB" value="RnB"/>RnB<br />
  <input type="checkbox" name="genre[]" id="Rock" value="Rock"/>Rock<br />
  <input type="checkbox" name="genre[]" id="Jazz"value="Jazz"/>Jazz<br />

  <p>
    <input type="submit" value="Next">
    <br />
  </p>
 </form>

From there, I am using the following code to make sure that they only use numbers 1,2, and 3 and a foreach loop to list what they have checked but how can I make sure they do not use the same number twice?

<body>
 The genre(s) you selected are: <br />
 <form id="form1" name="form1" method="post" action="musicresults.php">
  <?php
   $name = $_POST['genre'];

   if(isset($_POST['genre'])) {
    foreach ($name as $genre) {  
     ?>

     <input type="number" required="required" id="<?php echo $genre ?>" name="music[<?php echo $genre ?>]" max="3" min="1" />
     <?php echo $genre ?>
     <br /> 

     <?php
    }
   }
  ?>

  <input type="submit" name="button" id="button" value="Submit" />
 </form>
</body>

This was the old javascript code from the previous question but now the id="" is generated by PHP above:

 <script type="text/javascript">
    function item() {
        cake = Number(document.getElementById('cake').value);
        twizlers = Number(document.getElementById('twizlers').value);
        taffy = Number(document.getElementById('taffy').value);
        if (cake == twizlers) {
           alert("Some alert cake or twizlers");
        return false;
    } else if (twizlers == taffy) {
        alert("Some alert taffy or twizlers");
        return false;
    } else if (taffy == cake) {
        alert("Some alert taffy or cake");
        return false;
    } else {
        return true;
    }
  }
 </script>

How can this be done now? Does it have to be in a foreach loop? Any suggestions will be appreciated.

Answer:1

I am attempting to add a listener to a button I created using Bootstrap. <button type="button" id="buttonone" class="btn btn-default btn-lg good"> <span class="glyphicon glyphicon-minus" ...

I am attempting to add a listener to a button I created using Bootstrap. <button type="button" id="buttonone" class="btn btn-default btn-lg good"> <span class="glyphicon glyphicon-minus" ...

  1. jquery select bootstrap
  2. jquery select bootstrap tab
  3. jquery select bootstrap dropdown
  4. jquery.select-bootstrap.js
  5. jquery selector bootstrap
  6. jquery select bootstrap button
  7. jquery selector bootstrap modal
  8. jquery bootstrap select set value
  9. jquery bootstrap select multiple
  10. jquery bootstrap select add option
  11. jquery bootstrap select change
  12. jquery bootstrap select get value
  13. jquery bootstrap select plugin
  14. jquery bootstrap select refresh
  15. jquery bootstrap select option
  16. jquery bootstrap select plugin demos
  17. jquery bootstrap select value
  18. jquery bootstrap selectpicker
  19. jquery bootstrap multiselect
  20. jquery get selected bootstrap tab

As we know service worker is registered from the root of the project folder but, is there any way to fetch some static resources (css, js) from different domain(s)? Example : myWebsite.com // ...

As we know service worker is registered from the root of the project folder but, is there any way to fetch some static resources (css, js) from different domain(s)? Example : myWebsite.com // ...

  1. service worker cache resources
  2. service worker external resources
  3. developmental service worker resources
  4. service worker cache external resources

Building on my previous question relating to this script below. Is it possible to setValue to change after 10 matches, I would like to assign "found here" for the first 10 matches, then "something ...

Building on my previous question relating to this script below. Is it possible to setValue to change after 10 matches, I would like to assign "found here" for the first 10 matches, then "something ...

  1. google script help
  2. google apps script help
  3. google apps script get help
  4. google apps script function help

I am having issues reading this data: It looks like this: { "ok": true, "messages": [ { "text": "moo", "username": "bot", "type": "message", "subtype": "bot_message",...

I am having issues reading this data: It looks like this: { "ok": true, "messages": [ { "text": "moo", "username": "bot", "type": "message", "subtype": "bot_message",...