Solved

Jquery Wordpress Taxonomy

Posted on 2014-04-25
3
390 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 54

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 54

Expert Comment

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

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
In order to have all security and back ups taken care of, WordPress users can sign up for services with WP Engine.
This video teaches users how to migrate an existing Wordpress website to a new domain.
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…

785 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