Solved

Jquery Wordpress Taxonomy

Posted on 2014-04-25
3
393 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 56

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 56

Expert Comment

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

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The purpose of this video is to demonstrate how to manually back up a WordPress Database. This will be demonstrated using a Windows 8 PC. The Host used will be IPage.com Log into your Hosting account. IPage will be used for demonstration : Locat…
The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…

749 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