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 9148073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:10:24+00:00 2026-06-17T11:10:24+00:00

I cannot figure how to apply the condition to the result after the query.

  • 0

I cannot figure how to apply the condition to the result after the query.
This code was asked before but I wanted to enhance it

require(["dojo/parser", "dojo/ready", "dojo/query", "dojo/on", "dijit/form/Select", "dojo/domReady!"], function (parser, ready, query, on, Select) {
ready(function () {
    parser.parse();

    var select_Card = new Select({
        name: 'select_PCBA',
        options: [{
            label: "<span id='NotinUse'><b>&nbsp&nbsp&nbsp. . .</b></span>",
            value: "",
            selected: true
        }, {
            label: "<span id='NotinUse'><b>&nbsp&nbspMk7ABC Card</b></span>",
            value: "testdata1970_05"
        }, {
            label: "<span id='inUse'><b>&nbsp&nbspMk7CBC Card</b></span>",
            value: "testdata1970_10"
        }, {
            label: "<span id='NotinUse'><b>&nbsp&nbspMk10DC Card</b></span>",
            value: "testdata2060_03"
        }, {
            label: "<span id='NotinUse'><b>&nbsp&nbspMk6BC Card</b></span>",
            value: "dbProdigy"
        }, {
            label: "<span id='NotinUse'><b>&nbsp&nbspMk6NBC Card</b></span>",
            value: "dbProdigy_MK6N"
        }, ],
        style: {
            width: '150px'
        }
    }, "select_Card");

    select_Card.startup();


    on(select_Card, 'change', function(newValue)
    {
        if query('#inUse')
        {
            alert('Item selected is '+ newValue);
        }
        else
        {
            alert('Please select the only highlighted card');                           
        }
    });
    });
});

OR Please see my jsfiddle for your convenience.

Or do you have better way?

Please advise
Thanks

Clement

  • 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-17T11:10:26+00:00Added an answer on June 17, 2026 at 11:10 am

    I have updated your jsFiddle: http://jsfiddle.net/fredfortier/q5LC7/11/. A few things were wrong with it. I cleaned-up the “ready” stuff to make it run.

    I believe that there are a few issues with the structure of the code that you might want to clean-up. But I did not want to change your code too much so I just made it work. One major thing is that you were using the same ids multiple time. I changed it to class. Also, the query function is not scoped to a closure, it will search through the dom. So your condition in the event handler would never have worked.

    Again, I do not think that this code if very polished and could be tackled differently, but here it is working without major changes to what you had:

    require(["dojo/parser", "dojo/ready", "dojo/query", "dojo/on", "dijit/form/Select", "dojo/_base/array", "dojo/domReady!"], function (parser, ready, query, on, Select, array) {
    
        console.debug('rendering...');
        var select_Card = new Select({
            name: 'select_PCBA',
            options: [{
                label: "<span class='NotinUse'><b>&nbsp&nbsp&nbsp. . .</b></span>",
                value: "",
                selected: true
            }, {
                label: "<span class='NotinUse'><b>&nbsp&nbspMk7ABC Card</b></span>",
                value: "testdata1970_05"
            }, {
                label: "<span class='inUse'><b>&nbsp&nbspMk7CBC Card</b></span>",
                value: "testdata1970_10"
            }, {
                label: "<span class='NotinUse'><b>&nbsp&nbspMk10DC Card</b></span>",
                value: "testdata2060_03"
            }, {
                label: "<span class='NotinUse'><b>&nbsp&nbspMk6BC Card</b></span>",
                value: "dbProdigy"
            }, {
                label: "<span class='NotinUse'><b>&nbsp&nbspMk6NBC Card</b></span>",
                value: "dbProdigy_MK6N"
            }, ],
            style: {
                width: '150px'
            }
        }, "select_Card");
    
        select_Card.startup();
    
        on(select_Card, 'change', function(newValue)
        {
            console.debug('got selected value:', newValue, 'from options:', select_Card.options);
            array.forEach(select_Card.options, function(option) {
                if (option.value == newValue) {
                      console.debug('found selected option in the list: ', option);
                      if (option.label.indexOf("'inUse'") != -1) {
                            alert('Item selected is '+ newValue)
                      } else {
                            alert('Please select the only highlighted card');
                      }
                }
            });
        });
    

    });

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

Sidebar

Related Questions

I cannot figure out how to convert this code from C# to VB.net. It
The question is similar to this one , but I cannot figure how to
This is super straightforward stuff, it seems to me, but I cannot figure out
I come across this code in jsGarden, and I cannot figure the meaning to
I cannot figure out this positioning problem in Firefox. It doesn't seem to follow
I cannot figure out why this doesn't work. It seems so simple. It should
I cannot figure out how to write the following query using the DbFinderPlugin 1.2.2
I cannot figure out why I get this error during check-in. I checked in
I am still trying to figure out, why i cannot apply HTML formatting in
My friend and I have found this problem and we cannot figure out how

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.