Forum Replies Created

Viewing 1 replies (of 1 total)
  • Thread Starter snydez

    (@snydez)

    hi @champsupertramp

    below is the code i use

    
    /*Write here your own functions */
    
    function custom_negara_dropdown() { 	
      $coutries = array( 
           "FR" => "France", 
           "ES" => "Spain" ,
    	   "ID" => "Indonesia",
      ); 		
      
      return $coutries;         
    }
    
    function custom_provinsi_dropdown( $has_parent = false ) {
    	
    	$parent_option = $_POST['parent_option'];
    	
    	$all_options = array(
    		"ID" => array(
    			"11" => "Aceh",
    			"12" => "Sumatera Utara",
    			"13" => "Sumatera Barat",
    			"14" => "Riau",
    			"15" => "Jambi",
    			"16" => "Sumatera Selatan",
    			"17" => "Bengkulu",
    			"18" => "Lampung",
    			"19" => "Kepulauan Bangka Belitung",
    			"21" => "Kepulauan Riau",
    			"31" => "DKI Jakarta",
    			"32" => "Jawa Barat",
    			"33" => "Jawa Tengah",
    			"34" => "DI Yogyakarta",
    			"35" => "Jawa Timur",
    			"36" => "Banten",
    			"51" => "Bali",
    			"52" => "Nusa Tenggara Barat",
    			"53" => "Nusa Tenggara Timur",
    			"61" => "Kalimantan Barat",
    			"62" => "Kalimantan Tengah",
    			"63" => "Kalimantan Selatan",
    			"64" => "Kalimantan Timur",
    			"65" => "Kalimantan Utara",
    			"71" => "Sulawesi Utara",
    			"72" => "Sulawesi Tengah",
    			"73" => "Sulawesi Selatan",
    			"74" => "Sulawesi Tenggara",
    			"75" => "Gorontalo",
    			"76" => "Sulawesi Barat",
    			"81" => "Maluku",
    			"82" => "Maluku Utara",
    			"91" => "Papua Barat",
    			"94" => "Papua",
    		),
    		 "FR" => array(
             	"Paris" =>"Paris",
             	"Marseille" => "Marseille",
             	"Lyon" => "Lyon",
          	),
    	);
    	
    	$arr_options = array();
    	
    	if ( ! is_array( $parent_options ) ) {
          $parent_options = array( $parent_options );
       	}
    
        if( isset( $all_options[ $parent_option ] ) ){
    		$arr_options = $all_options[ $parent_option ];
    	}elseif( ! isset( $_POST['parent_option'] ) ) {
    
    		foreach( $all_options as $k => $opts ){
    			$arr_options = array_merge( $opts, $arr_options );
    		}
    
    	}
    
    	return $arr_options;
    	
    }
    
    function custom_kota_dropdown( $has_parent = false ){
    	$parent_option = $_POST['parent_option'];
    	
    	$all_options = array(
    		"11" => array(
    			"1101" => "Simeulue",
    			"1102" => "Aceh Singkil",
    			"1103" => "Aceh Selatan",
    			"1104" => "Aceh Tenggara",
    			"1105" => "Aceh Timur",
    			"1106" => "Aceh Tengah",
    			"1107" => "Aceh Barat",
    			"1108" => "Aceh Besar",
    			"1109" => "Pidie",
    			"1110" => "Bireuen",
    			"1111" => "Aceh Utara",
    			"1112" => "Aceh Barat Daya",
    			"1113" => "Gayo Lues",
    			"1114" => "Aceh Tamiang",
    			"1115" => "Nagan Raya",
    			"1116" => "Aceh Jaya",
    			"1117" => "Bener Meriah",
    			"1118" => "Pidie Jaya",
    			"1171" => "Banda Aceh",
    			"1172" => "Sabang",
    			"1173" => "Langsa",
    			"1174" => "Lhokseumawe",
    			"1175" => "Subulussalam",
    		),
    		"31" => array(
    			"3101" => "Kepulauan Seribu",
    			"3171" => "Jakarta Selatan",
    			"3172" => "Jakarta Timur",
    			"3173" => "Jakarta Pusat",
    			"3174" => "Jakarta Barat",
    			"3175" => "Jakarta Utara",
    		),
    		"37" => array(
    			"3201" => "Bogor",
    			"3202" => "Sukabumi",
    			"3203" => "Cianjur",
    			"3204" => "Bandung",
    			"3205" => "Garut",
    			"3206" => "Tasikmalaya",
    			"3207" => "Ciamis",
    			"3208" => "Kuningan",
    			"3209" => "Cirebon",
    			"3210" => "Majalengka",
    			"3211" => "Sumedang",
    			"3212" => "Indramayu",
    			"3213" => "Subang",
    			"3214" => "Purwakarta",
    			"3215" => "Karawang",
    			"3216" => "Bekasi",
    			"3217" => "Bandung Barat",
    			"3218" => "Pangandaran",
    			"3271" => "Bogor",
    			"3272" => "Sukabumi",
    			"3273" => "Bandung",
    			"3274" => "Cirebon",
    			"3275" => "Bekasi",
    			"3276" => "Depok",
    			"3277" => "Cimahi",
    			"3278" => "Tasikmalaya",
    			"3279" => "Banjar",
    		),
    	);
    	
    	$arr_options = array();
    		
    
    	if( isset( $all_options[ $parent_option ] ) ){
    		$arr_options = $all_options[ $parent_option ];
    	}elseif( ! isset( $_POST['parent_option'] ) ) {
    
    		foreach( $all_options as $k => $opts ){
    			$arr_options = array_merge( $opts, $arr_options );
    		}
    
    	}
    
    	return $arr_options;
    }
    

    and the screenshot of the form
    https://s4.gifyu.com/images/negara-202104081044.png
    https://s4.gifyu.com/images/provinsi-202104081045.png
    https://s4.gifyu.com/images/kota-202104081045.png

    thank you for your attention and assistance.

    • This reply was modified 5 years, 2 months ago by snydez.
Viewing 1 replies (of 1 total)