/    Sign up×
Community /Pin to ProfileBookmark

about validations

hi…….?

I am new person in javascript,I want to write a javascript function that will list all the elements in the div. such as if div contains 3textbox and 2 buttons .then function must list all the elements.and i want to set focus on the first div element from list how can i do that.it must be general as i am changing only content of div on different clicks. :confused:

such as
if you click on “album” button then first element in div is “albumname”
which is link <a href> and if you click on “login” button then first element is “textbox”.

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@vwphillipsJan 22.2009 — [CODE]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">


<head>
<title></title>
<script language="JavaScript" type="text/javascript">
<!--

function Order(but,nme){
var top=but.form[nme];
var p=top.parentNode.parentNode;
var els=p.getElementsByTagName('INPUT');
for (var ary=[],z0=0;z0<els.length;z0++){
ary.push(els[z0]);
}
for (var z1=0;z1<ary.length;z1++){
if (ary[z1]!=top){
p.appendChild(ary[z1].parentNode);
}

}
top.focus();
}
//-->
</script>

</head>

<body>

<form name="form" >
<input type="button" name="" value="tom" onclick="Order(this,'tom');">
<input type="button" name="" value="dick" onclick="Order(this,'dick');">
<input type="button" name="" value="harry" onclick="Order(this,'harry');">
<div >
<div><input name="tom" value="tom" ></div>
<div><input name="dick" value="dick" ></div>
<div><input name="harry" value="harry" ></div>
</div>
</form>
</body>

</html>[/CODE]
×

Success!

Help @nilk_cse spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.4,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...