Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Javascript HTML jQuery
Hi all,
 
Can anyone tell me how to close popup using jquery?
but the condition is, jquery code should be in javascript function.
 
My code:
function ValidateAboutYouMAIN()
{
    //alert("main method call");
    var myVar=validateAboutYou();
//    alert(myVar);
    if(myVar==0)
    {
        alert("value=0");
        $('#aboutYouEditable').fadeOut(500);
    }
    else
    {
        alert("value=1");
    }
}
In above code i check return value from function:
validateAboutYou()
and if it is 0, div -
aboutYouEditable
should be close.
 
I have tried by writing document.ready function but still its not working..
Please suggest me to close popup
Posted 17-Sep-12 3:04am
Edited 17-Sep-12 5:12am
v2
Comments
aspnet_regiis at 17-Sep-12 9:12am
   
$('#aboutYouEditable').hide(); will work for you
Sweetynewb at 18-Sep-12 3:20am
   
not working
aspnet_regiis at 18-Sep-12 5:16am
   
what is the id of div? show your html code
Sweetynewb at 18-Sep-12 5:20am
   
<div id="aboutYouEditable" class="hidden">
<form action="#" method="post">
<fieldset id="popup_aboutYou">
<dl class="commonForm">

<dt>
<label for="popup_title">Title:*</label>
</dt>
<dd>
<div class="normalFieldWrapper">
<select name="popup_title" id="popup_title">
<option value="">Select</option>
<option value="mr">Mr.</option>
<option value="ms">Ms.</option> </select>
<span id="list_error1" class="popupError" style="display:none"></span>
</div>
</dd>
<dt>
<label for="popup_firstname">First name:*</label>
</dt>
<dd>
<div class="normalFieldWrapper">
<input type="text" name="popup_firstName" id="popup_firstname" /><span id="list_error2" class="popupError" style="display:none"></span>
</div>
</dd>
<dt>
<label for="popup_middlename">Middle name:</label>
</dt>
<dd>
<div class="normalFieldWrapper">
<input type="text" name="popup_middleName" id="popup_middlename" /><span id="list_error3" class="popupError" style="display:none"></span>
</div>
</dd>
<dt>
<label for="popup_lastName">Last name:*</label>
</dt>
<dd>
<div class="normalFieldWrapper">
<input name="popup_lastName" type="text" id="popup_lastName" /><span id="list_error4" class="popupError" style="display:none"></span>
</div>
</dd>

<dt>
<label for="popup_genderMale">Gender:</label>
</dt>
<dd>
<div class="normalFieldWrapper">
<input name="gender" type="radio" class="radioButton" id="popup_genderMale"/>
<label for="genderMale" class="radioButtonLabel">Male</label>
<input name="gender" type="radio" class="radioButton" id="popup_genderFemale" />
<label for="genderFemale" class="radioButtonLabel">Female</label><span id="list_error6" class="popupError" style="display:none"></span>
</div>
</dd>

</dl>
</fieldset>
<div class="buttonWrapper"> <span>Cancel</span> <span class="mainActionbu
aspnet_regiis at 18-Sep-12 5:28am
   
Your HTML is wrong. Move the div inside the form tag. It should not be outside
 
<div id="aboutYouEditable" class="hidden">
<form action="#" method="post">
 
Should be
 

<form action="#" method="post">
<div id="aboutYouEditable" class="hidden">
Sweetynewb at 18-Sep-12 6:15am
   
ok i tried with your suggestion but still its not working.
its giving me error-
$ is not a function
 
And if i replace $ with - jQuery word it gives me exceptions which i didnt seen ever
aspnet_regiis at 18-Sep-12 7:11am
   
You have not included the jQuery library on the page.. You need to set up the webpage to use Jquery...
shabari7 at 17-Sep-12 9:27am
   
did u included a latest jquery file in ur page? and try using firebug add on for firefox to deal with client scripts .....
Sergey Alexandrovich Kryukov at 8-Feb-13 1:52am
   
What makes you posting a fake answer?! And even accepting it formally?! Cheating?
Do you know that a number of members already lost their memberships because of this kind of abuse?
—SA

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Try this:
function ValidateAboutYouMAIN()
{
    var myVar=validateAboutYou();
    if(myVar==0)
    {
        alert("value=0");
        $('#aboutYouEditable').fadeOut(500);
        window.close(); // You missed. Although you are using fadeout you need to use close function also.
    }
    else
    {
        alert("value=1");
    }
}
 
Hope it helps.
--Amit
  Permalink  
Comments
Sweetynewb at 18-Sep-12 2:58am
   
I tried your code, still its not working.
Actually popup is nothing but the div on same page..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 7,280
1 Sergey Alexandrovich Kryukov 6,059
2 Maciej Los 3,579
3 Peter Leow 3,383
4 CHill60 2,522


Advertise | Privacy | Mobile
Web02 | 2.8.140721.1 | Last Updated 20 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100