click button automatically using js.

Last post 05-16-2008 7:49 AM by lallouna85. 2 replies.

Sort Posts:

  • click button automatically using js.

    05-12-2008, 5:59 AM
    • Loading...
    • ams16
    • Joined on 05-12-2008, 9:48 AM
    • Posts 62

    I am havin a button and a timer in my design part.i need to click tat btn automatically once the time reaches 0 seconds.

    is tat possible.if so how?

  • Re: click button automatically using js.

    05-12-2008, 8:12 AM

    Hi,

    You can call the button click programatically

    // If timer = 0

    Page.ClientScript.RegisterStartupScript(this.GetType(),"click","<script language=javascript>document.getElementById('"+Button1.ClientID+"').click();</script>");

    HTH,
    Suprotim Agarwal

  • Re: click button automatically using js.

    05-16-2008, 7:49 AM
    • Loading...
    • lallouna85
    • Joined on 02-15-2008, 3:20 AM
    • Lebanon
    • Posts 141

    hi ams16, well instead of having a timer and dicrease it to zero you can in javascript

     

    setTimeout(myfunction,1000)

     

    function myfunction()

     {

            var myButton = document.getElementById('<%= button1.ClientID %>');

     

            if(myButton != null)

            {

                  myButton.click();
     

             }
     

     

     

    this will call the function after 1000 millisecond

     

     

    hope it helped 

    The Things That doesnot kill you make, you stronger
Page 1 of 1 (3 items)
Microsoft Communities
Page view counter