Doubt to use combobox

Asked

Viewed 61 times

1

Good Morning,

I have a final chair work for web development, where I need to create a crud for teams, players, create a style table of the Brazilian championship and create the rounds. I’ve managed to create the Ruds and the championship table but create the rounds is complicated. I thought I’d create a combobox to make the 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 team twice in the same round and if the value of textfield then step to some field of the database. Or if you have a better idea to give, thank you all.

  • Before adding the Time consult in the bank if this team is already in the round.

  • @Krismorte would do an if for example, to see if akele team this in the round,?

  • Yes. Since you didn’t post your code, it is difficult to give other ideas. If you are working with List you can simply remove the team from the list and reload the Box. Anyway.

  • I left the note at home and I’m at work at the moment but what I have on this screen 10 combobox Ex.: Time A X Time B. Where I insert a result for each match. And the combobox is generated from the BD.

  • From what I understand there this screen with the 10 combobox need not exist. Since it will be informed the results and for that the round must have already been registered. Example Round A Time1 xTime2 time3 xtim4 Round B Time1 xTime3 time2 xtim4

  • It would be something like happened today the round of Brasileirão, hence would for example register on the screen this round with the results. Ex.: Time A 2 x 1 Time C Time D 0 x 0 Time B. The excerpt from the work that talks about the result: To perform this work you can use the content seen in HTML, CSS, PHP, Database, Jquery, Javascript .

  • Then go back to my first comment. Every time you register you have to make a query in the bank.

  • I’m sorry to ask you this stupid question, but if I were to sign up, for example, team A as the lead team, for example, when choosing a visitor, wouldn’t Team A show up again? I would like to restrict this because surely my teacher will ask me for this validation. Thank you for your help and sorry to take your time.

  • Load the sender’s combobox and add an event to it to load the other box from the selected item excluding it

  • Thanks I’ll try.

Show 5 more comments

1 answer

1


Here’s a very basic example. I think this will solve your problem, but understand the logic.
Javascript is responsible for hiding the selected option and replicating in the other selects. That way you don’t have to send 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 answer is also based on the comments of your question.
I’m waiting for feedback.

  • thanks, I will apply your idea in my project

  • Hi, it didn’t work out, he keeps repeating, I put him inside the body tag or before?

  • That’s right. I forgot to put it, because I used jsFiddle that doesn’t need to put the body.

  • Right at the moment I am in the service and I have no way to check but yesterday had not worked out I will try as soon as I get back from class. Thank you

  • @Malfus all action events have to be on the body. I wait for feedback

  • Okay, I’ll only be able to give you the feedback tonight. Thanks for your help

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.