Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

101
Visualizações
Chromium Javascript Snippets. Set select box where the options are populated by a previous select box value

I am using Snippets in the developer tools of a Chromium based web browser (Edge). I am trying to fill out a select box on a form from a website. The issue is that the select box options are dynamically created and are based on a selection from another select box. Every time the 'parent' selection is made the page refreshes and populates the new options for the second select box.

Here is a function that I used to set the first select box, however it doesn't work on the second one. I think it has something to do with when the page refreshes but I am not sure.

//Find value by entered text

function selectElement(selectorType, selector, text) {    
    var e = document.getElementById(selector);
    //find value of text
    for (var i = 0; i < e.options.length; i++) {
    if (e.options[i].text === text) {
        e.selectedIndex = i;
        break;
      }        
    }
    if (selectorType == "id") {
        jqSelector = '#'+selector;
        $(jqSelector).val(e.value).change();
    }
    console.log(jqSelector, e.value);
  }
    

selectElement('id', 'mySelector', "My Text");
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda