Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

131
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!