Doubt to use the combobox

1

Good morning,

I have a final work of the web development chair, where I need to create a crud for teams, players, create a Brazilian championship style table and create the rounds. I already managed to create the cruds and the table of the championship but to create the rounds this complicated. I thought I created a combobox to make matches and use textfield to insert the results, create this is easy the problem is how can I do when using combobox to not allow the same time twice in the same round and if the textfield value then step to some field of the database. Or if you have a better idea to give, I thank you all.

    
asked by anonymous 09.06.2016 / 14:18

1 answer

1

Here's a super basic example. I believe this will solve your problem, however, understand the logic. Home JavaScript is responsible for hiding the selected option and replicating it on the other selects. That way you do not have to be sending a post every time you select an option

$('.select').on('change', function() {
  var option = $(this).val();
  $('.select').each(function() {
    $(this).find('option').show();
    $(this).find('option[value=' + option + ']').hide();
  });
});
<form action="#" method="POST">
  <select class='select' name="select[1][]">
    <option>Selecionar</option>
    <option value='A'>A</option>
    <option value='B'>B</option>
    <option value='C'>C</option>
    <option value='D'>D</option>
    <option value='E'>E</option>
  </select>
  <select class='select' name="select[1][]">
    <option>Selecionar</option>
    <option value='A'>A</option>
    <option value='B'>B</option>
    <option value='C'>C</option>
    <option value='D'>D</option>
    <option value='E'>E</option>
  </select>
  <br>
  <br>
  <input type="submit">
</form>

In PHP = >

  <?php
        echo '<pre>';
        print_r($_POST);
       echo '</pre>';
       exit;
/* Como o PHP vai capturar =>
    [select] => Array
            (
                [1] => Array
                    (
                        [0] => A
                        [1] => B
                    )

            )

*/
    ?>

NOTE: The result of this response is also based on the comments of your question.
I'm waiting for the feedBack.

    
09.06.2016 / 21:48