This morning I asked a pretty mundane question about my JS syntax, and someone suggested I use their code instead, so I went ahead with it because I know virtually Zero about JS.
Using my moderate PHP knowledge, I made a slight modification adding a second ID with an 'else if'
statement (see below) and was just wondering if you folks who know more about JavaScript could tell me if it all looks good?
Or maybe you would do it differently altogether?
window.onload = formfocus;
function formfocus()
{
var id_one;
var id_two;
id_one = document.getElementById( 'author' );
id_two = document.getElementById( 's_primary' );
if ( id_one )
{
id_one.focus();
id_one.value = '';
}
else if ( id_two )
{
id_two.focus();
id_two.value = '';
}
}
EDIT: I am slightly concerned about my window.onload = formfocus();
... but not really sure if there is any other way to accomplish what I want.