Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Jquery Wordpress Taxonomy

Posted on 2014-04-25
3
Medium Priority
?
428 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 60

Accepted Solution

by:
Julian Hansen earned 2000 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 60

Expert Comment

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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In order to have all security and back ups taken care of, WordPress users can sign up for services with WP Engine.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
The purpose of this video is to demonstrate how to Import and export files in WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Click on Too…
Suggested Courses

972 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