|
-
Aug 3rd, 2007, 02:26 AM
#1
Thread Starter
Addicted Member
Problem in javascript
Hi,
I create a div in html and set the link in form.If i click the link the div display and
close the div using close button that it closed.But while i try to click second time,there is no effect in the script.I think the problem may happened in the script.I put the code below.
function closeDivsms(item)
{
alert(item);
if(document.getElementById ('divSendSMS').style.visibility=='visible')
{
document.getElementById ('divSendSMS').style .display ="none";
document.getElementById ('divSendSMS').style .visibility ="hidden";
}
else
{
alert('9');
document.getElementById ('divSendSMS').style .display ="none";
document.getElementById ('divSendSMS').style .visibility ="hidden";
}
}
So give a solution to me.
As well As i create another div and check the same way on the above script.But that's working while i click second time.I put the code also.
function closeDivEmail(item)
{
alert(item);
if(document.getElementById ('divSendsms').style.visibility=='visible')
{
alert("divSendSMS");
document.getElementById ('divSendSMS').style .display ="none";
document.getElementById ('divSendSMS').style .visibility ="hidden";
}
else
{
alert("divemail");
document.getElementById ('divEmail').style .display ="none";
document.getElementById ('divEmail').style .visibility ="hidden";
}
}
Thanks
Failing to plan is Planning to fail 
-
Aug 3rd, 2007, 03:20 AM
#2
Re: Problem in javascript
You are setting the div to invisible and setting it's display to none for both condition. And just setting the display style property will work:
HTML Code:
function closeDivsms(item)
{
alert(item);
if(document.getElementById ('divSendSMS').style.display=='block')
{
document.getElementById ('divSendSMS').style .display ="none";
}
else
{
alert('9');
document.getElementById ('divSendSMS').style .display ="block";
}
}
Hope it helps you!!!
-
Aug 3rd, 2007, 04:01 AM
#3
Thread Starter
Addicted Member
Re: Problem in javascript
 Originally Posted by Harsh Gupta
You are setting the div to invisible and setting it's display to none for both condition. And just setting the display style property will work:
HTML Code:
function closeDivsms(item)
{
alert(item);
if(document.getElementById ('divSendSMS').style.display=='block')
{
document.getElementById ('divSendSMS').style .display ="none";
}
else
{
alert('9');
document.getElementById ('divSendSMS').style .display ="block";
}
}
Hope it helps you!!!
ya, I got it.Thanks Harsh.
Failing to plan is Planning to fail 
-
Aug 3rd, 2007, 05:05 AM
#4
Hyperactive Member
Re: Problem in javascript
hello frnd,
check out following links
http://www.quirksmode.org/js/blockinvi.html
if your problem is solved then mark the thread as RESOLVED
regards,
koolprasad2003
MCP, MCTS, Microsoft MVP [Asp.Net/IIS]
For more .NET development tips visit .NET Tips
If the post is useful then please  Rate it
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|