Solved

Jquery Wordpress Taxonomy

Posted on 2014-04-25
3
384 Views
Last Modified: 2014-04-25
Hi guys,

I have  a worpress taxonomy which has a list of terms

For example

>Shop
>>Fashion
>>Sports
>>etc

>Service
>>Accountant
>>Solicitor
>>etc


I wish to make a drop down menu (<select>)

Which lists all the parent terms ie >Service,

I also wish to have a second drop down which is disabled by default, which is only active when the parent select is selected and has a valid value,

So for example

Primary Select :Service

Secondary select

>>Accountant
>>Solicitor
>>etc


Thanks for the help in advanced

This does not need to be Ajax just a simple Javascript 2-d array I think

J
0
Comment
Question by:john_yourspace
  • 2
3 Comments
 
LVL 51

Accepted Solution

by:
Julian Hansen earned 500 total points
ID: 40022618
Something like this
<!doctype html>
<html>
<head>
<title>Test</title>
<script src="http://code.jquery.com/jquery.js"></script>
<script type="text/javascript">
var terms = {
  One : ['Item1','Item2','Item3'],
  Two: ['Item4','Item5','Item6']
};

$(function() {
  $('#parent').change(function() {
    var key = $(this).val();
    $('#child').empty();
    if (typeof terms[key] != undefined) {
      $(terms[key]).each(function(i,a) {
        $('#child').append($('<option/>').attr('value', a).html(a));
      });
    }
  });
});

</script>
<style type="text/css">
</style>
</head>
<body>
  <select id="parent">
    <option value="">Select One</option>
    <option value="One">One</option>
    <option value="Two">Two</option>
  </select>
  <select id="child">
  </select>
</body>
</html>

Open in new window

Working sample here http://www.marcorpsa.com/ee/t651.html
0
 

Author Closing Comment

by:john_yourspace
ID: 40022670
That worked perfect thanks for the help
0
 
LVL 51

Expert Comment

by:Julian Hansen
ID: 40022695
You are welcome - thanks for the points.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a page…
Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
The purpose of this video is to demonstrate how to prevent comment spam on a WordPress Website. This will be demonstrated using a Windows 8 PC. Plugin Akismet will be used. Go to your WordPress login page. This will look like the following: myw…
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now