I’ve three drop-down listing in cascade, I am utilizing the code of Ján Bočínec however it working simply the primary stage after I select the grade it not work, ought to allow the third drop-down listing and present the teams.
I see that the jQuery('#parent_grado').change
is just not working, I do not know if is as a result of is created dynamically.
Are you able to please assist me to seek out the bug or recommendation me if is feasible the best way that I attempt to created the online web page of my college thanks
That is my code modified
<?php
//Mum or dad youngster con ajax
perform parent_child_cat_select() { ?>
<script kind="textual content/javascript">
/* <![CDATA[ */
jQuery(document).ready(function() {
//segundo drop down
jQuery('#parent_grado').change(function(){
var parentgrado=jQuery('#parent_grado').val();
alert("hola");
// call ajax
jQuery.ajax({
url:'/dentrorealdelvalle/wp-admin/admin-ajax.php',
type:'POST',
data:'action=category_select_action&nameid=parent_grupo&parent_cat_ID=' + parentgrado,
success:function(results)
{
jQuery("#sub_grupo_div").html(results);
}
})
});
//primer drop down
jQuery('#parent_cat').change(function(){
var parentCat=jQuery('#parent_cat').val();
// call ajax
jQuery.ajax({
url:'/dentrorealdelvalle/wp-admin/admin-ajax.php',
type:'POST',
data:'action=category_select_action&nameid=parent_grado&parent_cat_ID=' + parentCat,
success:function(results)
{
jQuery("#sub_cat_div").html(results);
}
})
});
});
/* ]]> */
</script>
<type motion="<?php bloginfo('url'); ?>/" methodology="get">
<div id="parent_cat_div"><?php
$phrases=get_terms('grupos',
array(
'hide_empty' => false,
'mum or dad' => 0,
)
);
$datosparent="";
echo '<choose id="parent_cat" identify="escuelas">';
// Get classes as array
echo '<possibility disabled chosen worth> -- Seleccione Escuela -- </possibility>';
foreach ( $phrases as $time period ) :
echo '<possibility worth="' . $term->term_id . '">' . $term->identify . '</possibility>';
$datosparent=$datosparent . ',' . $term->term_id;
endforeach;
echo '</choose>';
?></div>
<div id="sub_cat_div"><choose identify="sub_cat_disabled" id="parent_grado" disabled="disabled"><possibility>Seleccione grado!</possibility></choose></div>
<div id="sub_grupo_div"><choose identify="sub_grupo_disabled" id="parent_grupo" disabled="disabled"><possibility>Seleccione grupo!</possibility></choose></div>
<div id="submit_div"><enter kind="submit" worth="View" /></div>
</type>
<?php }
//Primer dropdown grado
perform implement_ajax() {
$parent_cat_ID = $_POST['parent_cat_ID'];
$nameid = $_POST['nameid'];
if ( isset($parent_cat_ID) )
{
$phrases=get_terms('grupos',
array(
'hide_empty' => false,
'mum or dad' => $parent_cat_ID,
)
);
if ( $phrases ) {
echo '<choose id="' . $nameid . '" identify="grado">';
// Get classes as array
echo '<possibility disabled chosen worth> -- Seleccione Grado -- </possibility>';
foreach ( $phrases as $time period ) :
echo '<possibility worth="' . $term->term_id . '">' . $term->identify . '</possibility>';
endforeach;
echo '</choose>';
} else {
?><choose identify="sub_cat_disabled" id="sub_cat_disabled" disabled="disabled"><possibility>No youngster classes!</possibility></choose><?php
}
die();
} // finish if
}
add_action('wp_ajax_category_select_action', 'implement_ajax');
add_action('wp_ajax_nopriv_category_select_action', 'implement_ajax');//for customers that aren't logged in.
Thanks on your assist