form filter based on jQuery works for archive-ajut.php category

This commit is contained in:
jorge 2023-01-13 20:23:42 +01:00
parent 4f2630c4c1
commit de60c363e3
1 changed files with 12 additions and 4 deletions

View File

@ -79,8 +79,8 @@ if( ! function_exists( 'ofisuport_ajuts_filters_form' ) ):
<?php }; //end if type checkbox ?>
<?php }; //end foreach groupkey field ?>
<p><b>Results:</b> <span id="results"></span></p>
<button type="button" name="submit-ajut" class="button-more">enviar</button>
<?php //echo '<p><span id="filterlink"></span></p>';?>
<p><a id="submitfilteredlink" name="submit-ajut" class="button button-more" href="">enviar</a> </p>
</form>
<?php //close the form and subit ?>
@ -95,7 +95,8 @@ if( ! function_exists( 'ofisuport_ajuts_filters_form' ) ):
(function($) {
// change
$('#archive-filters').on('click', 'button', function(){
//$('#archive-filters').on('click', 'button', function(){
$('#archive-filters').on('click', 'input', function(){
// vars
var url = '<?php echo home_url('ajuts/'); ?>';
@ -139,6 +140,8 @@ if( ! function_exists( 'ofisuport_ajuts_filters_form' ) ):
};
});
// remove last ','
valueschecked = valueschecked.slice(0, -1);
// save last cycled filtered value already calculated field=val01,val02,val03
appendtoURL += eachfiltered +'=' +valueschecked +'&';
@ -147,8 +150,13 @@ if( ! function_exists( 'ofisuport_ajuts_filters_form' ) ):
// update url
url += '?' +appendtoURL;
// show or modify the url
//alert( url );
//$('#filterlink').text(url);
alert( url );
// convert a href url to new value
$('#submitfilteredlink').attr('href',url);
});