• Hello, is it possible to make the selected dropdown option submit different data than the display choice? For example, we want to submit the woocommerce region codes, but have them in human readable format in the form dropdown:

    State >>>>>>>> StateCode
    Northland >>>>>> NL
    Auckland >>>>>>> AK
    Waikato >>>>>>>> WA
    Bay of Plenty >> BP

    We want to achieve the same result as you would with the HTML <option> value Attribute

    <option value=”NL”>Northland</option>

    • This topic was modified 6 years, 7 months ago by bt_dev.
Viewing 1 replies (of 1 total)
  • Thread Starter bt_dev

    (@biotrace)

    I found out how this can be achieved with a code snippet:

    function getState() {
    
          $state = [
            "ACT" => "AU > Australian Capital Territory",
            "NSW" => "AU > New South Wales",
            "NT" => "AU > Northern Territory",
    	"QLD" => "AU > Queensland",
            "SA" => "AU > South Australia",
            "TAS" => "AU > Tasmania",
    	"VIC" => "AU > Victoria",
            "WA" => "AU > Western Australia",
            "AK" => "NZ > Auckland",
            "BP" => "NZ > Bay of Plenty",
            "CT" => "NZ > Canterbury",
    	"HB" => "NZ > Hawke’s Bay",
            "MW" => "NZ > Manawatu-Wanganui",
            "MB" => "NZ > Marlborough",
    	"NS" => "NZ > Nelson",
            "NL" => "NZ > Northland",
    	"OT" => "NZ > Otago",
            "SL" => "NZ > Southland",
            "TK" => "NZ > Taranaki",
    	"TM" => "NZ > Tasman",
            "WA" => "NZ > Waikato",
            "WE" => "NZ > Wellington",
    	"WC" => "NZ > West Coast"		
          ];
    
    return $state;
    
    }
    
    function getCountry() {
    
          $country = [
            "AU" => "Australia",
            "NZ" => "New Zealand"
          ];
    
    return $country;
    
    }

    You must make sure to add the appropriate callback to the corresponding form field (eg. getCountry / getState). Also must use the correct Meta Key for the appropriate field.

    Hope this helps someone else.

    • This reply was modified 6 years, 7 months ago by bt_dev.
    • This reply was modified 6 years, 7 months ago by bt_dev.
Viewing 1 replies (of 1 total)
  • The topic ‘Form Dropdown: Submit different data than what is displayed?’ is closed to new replies.