/    Sign up×
Community /Pin to ProfileBookmark

focus is not working in FF

HI,
<html>
<head>

[CODE]
<script language=”JavaScript”>
function checkme(strVal){

if(strVal==’id’)
{
alert(‘true’);
document.forms[0].id.focus();

} else {
alert(‘false’);
document.forms[0].dept.focus();
}
}
</script>

</head>
<body>
NAME..<input type=”text” name=”name” value=”” size=”5″ maxlength=”4″ onChange=”checkme(this.value)”/><br>
ID….<input type=”text” name=”id” value=””/><br>
DEPT..<input type=”text” name=”dept” value=””/><br>
</body>
</html>
[/CODE]

Is there any thing wrong… can any bady tel me..

thx & rgds,
Ajay

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@JMRKERJul 05.2007 — I don't see a <form...> defined in your code to reference for the focus().

Have you been checking the error console?
Copy linkTweet thisAlerts:
@msg2ajayauthorJul 05.2007 — Is it possible to set values dynamically?....

[CODE]

<html>

<head>
<script language="JavaScript">

function checkme(strVal){

alert(strVal);
var id=strVal;
alert(id);
[B]document.forms[0].+id+.focus();[/B]
}
</script>

</head>
<body>
<form>
NAME..<input type="text" name="empName" size="5" maxlength="4" onChange="checkme(this.value)"/><br>
ID....<input type="text" name="id" value=""/><br>
DEPT..<input type="text" name="dept" value=""/><br>
</form>
</body>
</html>
[/CODE]
×

Success!

Help @msg2ajay 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.6,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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