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

  • Home
  • SEARCH
  • 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 7811363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:08:09+00:00 2026-06-02T04:08:09+00:00

I’m trying to make a piece of dojo Code work and having a bit

  • 0

I’m trying to make a piece of dojo Code work and having a bit of a hard time.
The intention behind it goes like this:

1- Have a select fire an onChange event that retrieves a list of options through dojo.xhrGet.
2- Have each one of the options retrieved get its own onclick event associated/binded to it and the function that it fires takes 2 arguments

Problem: At this point the onClick event on the options fires as soon as it is retrieved through Ajax and doesn’t pass the firt argument. The events stop firing after that (a click produces nothing).

Thank you for your feedback in advance. The Code follows

JS

function checkAvailable(i){
    var id_prog = 'programa_'+i;
    var id_coreo = 'coreografia_'+i;

    var prog = dojo.byId(id_prog).value;

    dojo.xhrGet({
        url:"ajaxCoreo.php",
        handleAs:"text",
        content: {
            programa: prog,
            item: i
        }, 
        load: function(data){
            var targetNode = dojo.byId(id_coreo);
            dojo.place(data,targetNode,"only");
            dojo.byId(id_coreo).disabled = false;
            var callback = function(evt){
                var j = evt.target.innerHTML;

                checkPack(j,i);
                console.log('write me if you fire inside first function');
            };
            dojo.query("#coreografia_1>option").connect('click', callback);
            setValor(i);
        }

    });

}



    function checkPack(j,i){
    console.log('write me if you fire inside second function');
    console.log(j);
    console.log(i);

    var num = j;
    var id_prog = 'programa_'+i;
    var id_coreo = 'coreografia_'+j;

    var prog = dojo.byId(id_prog).value;

    dojo.xhrGet({
        url:"ajaxPack.php",
        handleAs:"text",
        content: {
            programa: prog,
            coreo: j
        },
        load: function(data){

            if(data=="true"){
                dojo.query("option[value="+num+"]").forEach(dojo.destroy);
                alert('O Pack escolhido já foi encomendado previamente.');
                setValor(i);
            }

        }

    });

}

HTML

<select name="programa[]" id="programa_1" onChange="checkAvailable(1)" title="obrigatorio">
                <option value="0">Choose your program</option> 

</select>
 <select name="coreografia_1" id="coreografia_1" disabled="disabled" title="obrigatorio">
                <option value="0" selected="selected">Escolha Um Programa</option> //this is the node that is populated by the first xhrGet call
            </select>

EDIT: I’ve edited the code to reflect the changes to it and added the html

  • 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-02T04:08:11+00:00Added an answer on June 2, 2026 at 4:08 am

    From my experience, if you spend more than 1 day trying to track a cross-brower issue it’s probably somewhere on your basic html knowledge or your basic Js concepts.

    This one was related to the fact that only FF manages onclick events directly attached to option tag. For the rest of the gang you need to attach the onchange to the parent.

    So here is the final version of the working code, in case anyone comes upon a similar issue

    function checkAvailable(i){
        var id_prog = 'programa_'+i;
        var id_coreo = 'coreografia_'+i;
    
        var prog = dojo.byId(id_prog).value;
    
        dojo.xhrGet({
            url:"ajaxCoreo.php",
            handleAs:"text",
            content: {
                programa: prog,
                item: i
            }, 
            load: function(data){
                var targetNode = dojo.byId(id_coreo);
                dojo.place(data,targetNode,"only");
                dojo.byId(id_coreo).disabled = false;
                var callback = function(evt){
                    var j = evt.target.value;
                    checkPack(j,i);
                };
                dojo.query("#coreografia_"+i).connect('onchange', callback);
                setValor(i);
            }
    
        });
    
    }
    
    
    
        function checkPack(j,i){
        console.log('write me if you fire inside second function');
        console.log(j);
        console.log(i);
    
        var num = j;
        var id_prog = 'programa_'+i;
        var id_coreo = 'coreografia_'+j;
    
        var prog = dojo.byId(id_prog).value;
    
        //Confirma Se não há encomendas previas deste pack (um máximo de 2 anteriores)
    
        dojo.xhrGet({
            url:"ajaxPack.php",
            handleAs:"text",
            content: {
                programa: prog,
                coreo: j
            },
            load: function(data){
    
                if(data=="true"){
                    dojo.query("#coreografia_"+i+" option[value="+num+"]").forEach(dojo.destroy);
                    alert('O Pack escolhido já foi encomendado previamente.');
    
                }
    
            }
    
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I have this code to decode numeric html entities to the UTF8 equivalent character.
I would like to run a str_replace or preg_replace which looks for certain words

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.