Skip Navigation

[Resolved] set default taxonomy of form by passing url id parameter

This support ticket is created 4 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 2 replies, has 2 voices.

Last updated by meirk 4 years, 8 months ago.

Assisted by: Minesh.

Author
Posts
#1534545

I am trying to set a default category in a form by setting a parameter in the url
i already tried this js:



jQuery( document ).ready(function() {
    jQuery('#category select option[value="12"]').attr("selected",true);
  

})

this works...

but how can i change the value from 12 to a url parameter?

#1534961

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

You need to add the jQuery code to grab the URL param value.

For exmample:

jQuery(document).ready(function($){
  $.urlParam = function(name){
    var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
    if (results==null){
       return null;
    }
    else{
       return decodeURI(results[1]) || 0;
    }
}
 param =  $.urlParam('student'); 
   
jQuery('#category select option[value="'+param+'"]').attr("selected",true);
});

Where:
- student with your URL param name

#1535071

My issue is resolved now. Thank you very much!!!!