Results 1 to 4 of 4

Thread: Problem in javascript

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2007
    Posts
    241

    Thumbs up 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

  2. #2
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    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!!!
    Show Appreciation. Rate Posts.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jun 2007
    Posts
    241

    Talking Re: Problem in javascript

    Quote 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

  4. #4
    Hyperactive Member koolprasad2003's Avatar
    Join Date
    May 2007
    Location
    India
    Posts
    443

    Arrow 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
  •  



Click Here to Expand Forum to Full Width