Results 1 to 5 of 5

Thread: div id

  1. #1
    Join Date
    Aug 2009
    Posts
    74
    Thanks
    7
    Thanked 1 Time in 1 Post

    Default div id

    hi

    is there a way to get randomly div id inorder.

    wht i mean exactly is

    suppose there r 3 div tags with id's 1,2,3 when i first click a button the first div id should be called in the javascript function and whn i click the button next time it should call second div id and this should continue according to id is this possible if it is possilble plz help me out


    suggestions are also accepted

  2. #2
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,891
    Thanks
    2
    Thanked 441 Times in 435 Posts

    Default

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    
    <head>
      <title></title>
    <script  type="text/javascript">
    /*<![CDATA[*/
    function Next(){
     var args=Next.arguments;
      if (!args[0].nu){
       args[0].nu=0;
      }
      alert(args[args[0].nu+1]);
      args[0].nu=++args[0].nu%(args.length-1);
    }
    /*]]>*/
    </script></head>
    
    <body>
    <input type="button" name="" value="TEST" onclick="Next(this,'ID1','ID2','ID3');"/>
    </body>
    
    </html>
    Vic
    God Loves You and will never love you less.
    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

  3. #3
    Join Date
    Aug 2009
    Posts
    74
    Thanks
    7
    Thanked 1 Time in 1 Post

    Default

    well thnks for tht but wht i want is simillar to this but not the above one bcoz iwant that with my div tags preseent in my form for example

    if my form contains three div tags and one next button and when i click next button for first time i should get value of my first div tag and second and third

  4. #4
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,891
    Thanks
    2
    Thanked 441 Times in 435 Posts

    Default

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    
    <head>
      <title></title>
    <script  type="text/javascript">
    /*<![CDATA[*/
    function Next(){
     var args=Next.arguments;
      if (!args[0].nu){
       args[0].nu=0;
      }
      alert(document.getElementById(args[args[0].nu+1]).innerHTML);
      args[0].nu=++args[0].nu%(args.length-1);
    }
    /*]]>*/
    </script></head>
    
    <body>
    <input type="button" name="" value="TEST" onclick="Next(this,'ID1','ID2','ID3');"/>
    <div id="ID1" >Div ID1</div>
    <div id="ID2" >Div ID2</div>
    <div id="ID3" >Div ID3</div>
    </body>
    
    </html>
    Vic
    God Loves You and will never love you less.
    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

  5. #5
    Join Date
    Aug 2009
    Posts
    74
    Thanks
    7
    Thanked 1 Time in 1 Post

    Default

    thnks that is wht i exactly looking for.now when i click on the first time div ID1 will be triggered. can we perform any action from that means can i move tht div ID1 from one place to another place(exactly center of the page)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •