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

139
Visualizações
Conditionally Fill In Fields WordPress

I'd like some help with the following:

So we've implemented a custom form as there are various fields that are needed to be captured however we're looking at ways to better handle user error with the following:

When a person enters their Estate name it should autofill certain fields such as the Postal Code and another drop down it should select a certain suburb.

Even if the case is a matter of if's and else ifs it would work but how do we set the fields in.

The idea I think would be to use JS to grab the ID and setting the value accordingly.

Something in JS like

<script type="text/JavaScript"> 
    
    function onChangeFunc(){
    
var estate_name = document.getElementById('billing_selections').value;  
var suburb = document.getElementById('billing_suburb');

if estate_name == 'funplace' {
    document.getElementById("billing_suburb").value = suburb.options[complex_name.selectedIndex].text;

document.getElementById('billing_postcode').value = 10120;

}
}

However how does one do that with the php field

    
              $fields['billing_selections'] = array(
         'label' => __('Complex Selection', 'woocommerce'), // Add custom field label
        'placeholder' => _x('Complex Selection', 'placeholder', 'woocommerce'), // Add custom field placeholder
        'required' => false, // if field is required or not
        'clear' => false, // add clear or not
        'type'  => 'select',
        'options'   => array(
         '' => 'Please select',
                        'funplace'  => 'Fun Place', 

                        
        ),    
        'class' => array('my-css'),
        'priority' => 9,// 
   );

So a selection in the complex name will then fill Postal Code, City, and a value from a drop downs of Suburbs.

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