Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
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:
C#
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
Updated 17-Sep-12 5:12am
v2
Comments
bbirajdar 17-Sep-12 9:12am    
$('#aboutYouEditable').hide(); will work for you
Sweetynewb 18-Sep-12 3:20am    
not working
bbirajdar 18-Sep-12 5:16am    
what is the id of div? show your html code
Sweetynewb 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
bbirajdar 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">

1 solution

Try this:
JavaScript
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
 
Share this answer
 
Comments
Sweetynewb 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900