Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8915273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:56:16+00:00 2026-06-15T04:56:16+00:00

How can I trigger this function if either .ranking or .complaint select are changed?

  • 0

How can I trigger this function if either “.ranking” or “.complaint select” are changed?

This change function adds and/or remove values from “increase_priority1” when the user selects a complaint and ranks the importance level of the issue. At the moment it’s only being triggered when “ranking” changes, and therefore if the user changes the issue but not the importance level it isn’t changing the value accordingly.

var $increase_priority1 = $(".increase_priority1");
// If value is "Shoulders", complaint was Shoulders too small (select name=Shoulders value=Too_small) and it was assigned a level 1 priority (select class="ranking shoulders" value=1). 
// var's for other issues and priority levels go here

$(".ranking, .complaint select").change(function () {
   var name = $(this).data("name"); //get priority name    

   if ($(".complaint select").val() === "Too_small" && $(this).val() == 1 && !$(this).data("increase_priority1")) {
       //rank is 1, and not yet added to priority list
       $("<option>", {
           text: name,
           val: name
       }).appendTo($increase_priority1);
       $(this).data("increase_priority1", true); //flag as a priority item
   }
   if ($(this).data("increase_priority1") && ($(this).val() != 1 || $(".complaint select").val() != "Too_small")) {
       //is in priority list, but now demoted
       $("option[value=" + name + "]", $increase_priority1).remove();
       $(this).removeData("increase_priority1"); //no longer a priority item
   }
   // Similar If Statements to set & unset other elements go here
});

There are several complaint and ranking elements, reflecting the various areas customers complain about and ranking on a scale of 1 – 5.

Fiddle which shows this in context: http://jsfiddle.net/chayacooper/vWLEn/168/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T04:56:18+00:00Added an answer on June 15, 2026 at 4:56 am

    It would probably be easier if you restructured your code. How about this:

    HTML:

    <label for="priority1Issues">First Priority</label>
    <select id="priority1Issues" class="priorityIssue" multiple></select>
    
    <label for="priority2Issues">Second Priority</label>
    <select id="priority2Issues" class="priorityIssue" multiple></select>
    
    <br />
    <div class="complaint">
        <label for="shoulders">Shoulders</label>
        <select id="shoulders" class="complaintOpt complaintItem">
            <option value="Null">Select</option>
            <option value="too_big">Too Big</option>
            <option value="too_small">Too Small</option>
        </select>
    
        <label for="shouldersRanking">Ranking</label>
        <select id="shouldersRanking" class="complaintOpt complaintRanking">
            <option value="Null">Select</option>
            <option value="1">1</option>
            <option value="2">2</option>
        </select>
    </div>
    

    Now you can use the <div> with class complaint to selectively target it’s content:

    JavaScript:

    $('.complaint select.complaintOpt').change(function() {
        var $container = $(this).parent(),
            $item = $container.find('.complaintItem'),
            itemId = $item.attr('id'),
            itemVal = $item.val(),
            itemText = $item.find('option[value=' + itemVal + ']').html(),
            rank = $container.find('.complaintRanking').val();
    
        // Ignore if not a complete complaint
        if((itemVal == 'Null') || (rank == 'Null')) {
            return;
        }
    
        // Remove any existing complaint (using the CSS class to target the correct option)
        $('select.priorityIssue option.' + itemId).remove();
    
        // Add new complaint (we include a CSS class to make it easier to refer to this
        //   particular type of complaint later, if necessary)
        $('#priority' + rank + 'Issues')
            .append($('<option>' + itemText + '</option>').addClass(itemId));
    });
    

    You should now be able to duplicate the ‘complaint div’ for other items (just make sure you change the IDs of the <select> elements in the new div). There is an example here: http://jsfiddle.net/6YnQd/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does this mean I can't update another table from a trigger if I'm using
I have this trigger which works functionally (as far as I can tell by
The trigger below is delaying my insert response. How can I prevent this? create
Stripped down code shows that I can change an attribute, in this case data-split-icon,
This is my situation, how can I fix this? broswer.css tried to remove- but
I want to trigger this function, which uses the jquery's post method, when a
This should be simple, but I can't get it to work when the 'trigger'
In the an object called Response this works to trigger a function on .ready
I have a dropdown that triggers an ajax call when its changed: $('.travel-to').change(function(){ $.ajax({
May I know know I can trigger system to repaint nth row in JList?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.