1

I've got a div that starts out as hidden, and shows up when a button is clicked. There is another button on the div, and the onclick event calls this function:

    function popuppage2OK() {
        alert("you clicked ok!");
        var x = new Object();
        x.name = $("#boxforname").val();    //this is a text input
        x.option = $("#boxforoption").val();//this is a text input
        alert("hiding newfactorpage2");
        $("#popupform").hide();             //this is a div containing the text inputs and the button with the onlcick event that calls this function
        alert("popupform hidden");
        displaystuff();                     //another function ive written that needs to be called
        alert("this is after the display attempt");
    }

My probelm is that the only line that seems to execute is the line to hide the div. None of the alert boxes appear, and the displaystuff() function doesn't get executed, but the div does go back to being hidden. Any thoughts on why lines of code might get skipped like that?

7
  • are you using firefox? try another browser if so. Commented Jul 27, 2011 at 18:00
  • can we see more of the javascript? the function looks ok, however like Eric says the problem probably exists elsewhere and it is not manifesting itself until you enter said function. Commented Jul 27, 2011 at 18:03
  • Do you see errors in the JavaScript console? Commented Jul 27, 2011 at 18:06
  • I'm using IE. I've spent the past 5 hours trying to fix this problem. Once I posted this question, I ran it again, as-is for the hundredth time, and it just...worked. Didn't change a thing. Commented Jul 27, 2011 at 18:08
  • did you ever get round to finding out the problem? Commented Jan 4, 2016 at 12:43

2 Answers 2

1

When do you attach the eventhandler to the button inside the div ?

You should do it after the page has done loading, so in Jquery you can do something like:

$(document).ready(function () {
    //attach the eventhandler here 
})
Sign up to request clarification or add additional context in comments.

1 Comment

It's in the button's html. <input type="button" value="OK" onclick="popuppage2OK()">
0

Usually this kind of behavior happens when you've got an error in your javascript. Check to ensure that all of your selectors are valid and that there aren't any errors elsewhere.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.