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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:31:02+00:00 2026-06-10T15:31:02+00:00

Basically I have a script the function hola () that should return the value

  • 0

Basically I have a script the function “hola ()” that should return the value of 1 if the radio button value is 1. But for some reason when I try to get the return value in another function i never get it.

The form works perfectly.. the only issue is that it doesnt return the value

Can anyone tell me what i did wrong?? thanks

$(document).ready(function(){
    function hola() {
        $("form[name=yN]").show("slow");
        $('input[type=radio]').click( function (){
            var opt = $(this).attr("value");

            if (opt == "1") {
                this.checked = false;
                $("form[name=yN]").hide("slow");
                return 1;
            }

            if (opt == 0) {
                $("p").html ("ok");
                this.checked = false;
            }
        }) 
    }

    $("#iForm").submit( function(event){
        event.preventDefault();

        var user = $("input[name=username]").val();
        var password = $("input[name=password]").val();
        var dbName = $("input[name=dbName]").val();
        var server = $("input[name=server]").val(); 

        $.get("1.php", 
              {username: user, password: password, dbName: dbName, server: server },
              function(data){
                 if (data == "The table PAGE exists" || data == "The table SUBJECTS exists" || data == "The table USERS exists" ) {
                    // CALLING THE hola () function and expecting a return 
                    var opt = hola();
                    $("p").html(data + opt);
                 }
              }
        )
    })
})

HTML

<!-- Yes or No form -->
<form  name="yN" style= "display: none; margin-left: auto; margin-right: auto; width: 6em">
<input type="radio" name="yN" value="1">yes</input>
<input type="radio" name="yN" value="0">no</input>
<button id=1 >click me!</button>
</form>

<!-- Login Form -->
<form id="iForm"  style= "display: show">
<label id="username" >Username</label>
<input id="username" name="username"/>
<label id="password">Password</label>
<input id="password" name="password" />
<label id="server" >Server</label>
<input id="server" name="server"/>
<label id="dbName" >dbName</label>
<input id="dbName" name="dbName"/>

<input type="submit" value="submit" />
</form>
<p> </p>
  • 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-10T15:31:03+00:00Added an answer on June 10, 2026 at 3:31 pm

    Event handlers cannot return values because they’re called asynchronously*.

    Your existing hola() function will return immediately and the return statements in the click handlers are only called much later, i.e. when the button is clicked.

    My approach would be this, using jQuery deferred objects (jQuery 1.6+):

    function hola() {
        var def = $.Deferred();
    
        // show the popup confirm form
        ...
    
        $('input[type=radio]').click(function() {
            // determine return value
            ...
    
            // send it back to anything waiting for it
            def.resolve(retval);
        });
    
        // return a _promise_ to send back a value some time later
        return def.promise();
    }
    
    $.get("1.php", { ... }).done(function(data) {
        if (...) {
            hola().done(function(opt)) { // will be called when the promise is resolved
                $("p").html(data + opt);
            });
        }
    });
    

    If you prefer, instead of returning the opt value you could use def.reject() to indicate “non-acceptance” and then use a .fail handler to register a handler to be called for that condition.

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

Sidebar

Related Questions

I have a simple script that does some search and replace. This is basically
I have a bash script which serves as a driver basically. For some reason
I have (basically) this code - <script type=text/javascript language=javascript> $(document).ready(function() { $(#loadDiv).load(mypage.html, function(){ alert($(#someText).text())
In my script, I have a function foo which basically uses pynotify to notify
So basically I have a PHP script that takes all the images from the
I have a script that I'm trying to get working. Basically, what I'm trying
Basically, I have a script that cannot see an existing directory on the OS
I am stuck with a peculiar issue here. I have a script that basically
Basically I have a php script located on a sever that generates a JSON
I have this script that basically will show a product or products based on

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.