Forum Moderators: open
I am programmer but not in JavaScript, however it seems to be the best way to get a solution within my project. I need a dynamical setFocus-Function, what seems to be pretty easy but I don't find the correct syntax. -It should look like this:
<script language="javascript">
function setFocus(ctrlID){
document.forms[0].ctrlID.focus();
}
</script><body>
<FORM ...>
<INPUT id="TBFA" ...>
<INPUT id=...onchange="javasript:setFocus(TBFA);">
</FORM>
</body>
Can anyone help?
thanx - Peter
2)
setFocus(TBFA)
The argument is a string (since is an id)
Quote it.
3)
document.forms[0].ctrlID.focus();
To put arbitrary memberNames in member chains, use []:
document.forms[0][ctrlID].focus();
It may be better to either
a) Change the id attribute to a name attribute
b) Use getElementById instead
document.getElementById(ctrlID).focus()