PDA

View Full Version : div id



hemi
11-23-2009, 11:59 AM
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

vwphillips
11-23-2009, 12:26 PM
<!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>

hemi
11-24-2009, 05:21 AM
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

vwphillips
11-24-2009, 08:21 AM
<!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>

hemi
11-24-2009, 10:34 AM
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)