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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:06:37+00:00 2026-05-29T11:06:37+00:00

Using jQuery (1.7), and not jQueryUI – (how) would it be possible to accomplish

  • 0

Using jQuery (1.7), and not jQueryUI – (how) would it be possible to accomplish the following?

  • Call function 1
  • Within function 1, a variable is defined and set to the
    outcome of function 2
  • When called, function 2 ‘on the fly’ creates 2 buttons, if
    the first is clicked a value of ‘true’ is returned, the second returns ‘false’
  • Within function 1, the variable being set to the outcome of function 2 should wait until there had been user input and a value has been returned
  • This value should then be evaluated

Is there any way to do this in jQuery without using an interval/timeout etc to keep looking for an intermediate value being set to the users input?

I’ve outlined the principle below:

function function1(){

    var myVariable=function2;
    // nothing should happen at this point until function2 has returned a response
    if(myVariable){
        alert('true');
    }else{
        alert('false');
    }
}


function function2(){

    var yesbutton=$("<input type='submit' value='yes' />");
    var nobutton=$("<input type='submit' value='no' />");
    $('body').append(yesbutton)
    $('body').append(nobutton)
    nobutton.click(function(){
        return false;
    });
    yesbutton.click(function(){
        return true;
    });

}


function1();

As always, many thanks for any help!

  • 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-05-29T11:06:38+00:00Added an answer on May 29, 2026 at 11:06 am

    It is possible, just maybe not in the way you expected it to be.

    function function1(){
    
        var myVariable=function2();
        // nothing should happen at this point until function2 has returned a response
        myVariable.done(function(){
            alert('true');
        }).fail(function(){
            alert('false');
        });
    }
    
    
    function function2(){
        var deferred = $.Deferred();
    
        var yesbutton=$("<input type='submit' value='yes' />");
        var nobutton=$("<input type='submit' value='no' />");
        $('body').append(yesbutton)
        $('body').append(nobutton)
        nobutton.click(deferred.reject);
        yesbutton.click(deferred.resolve);
    
        return deferred.promise().always(function(){
            yesbutton.add(nobutton).remove();
        });
    
    }
    
    
    function1();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using jQuery, the following is not working in FF, but it is in IE
I am using jQuery .load to call an action but it is not found.
I have the following script which does not work. it should be using jquery
[edit] I am NOT using jquery in this app. Looking for a way to
I have a little problem about using jQuery (I really do not know jQuery
this is the problem: I'm using javascript and JQuery (not UI) to drag nested
I am trying to get an element using JQuery's selector, but it does not
I want to do a simple drag-drop using jQuery. I have not done anything
I have a problem with selecting not first selector using attributeContains jQuery('div[id*=abc]:not(:first)').hide();
How can I manipulate using JavaScript (JQuery) a site, not in my server, that

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.