/    Sign up×
Community /Pin to ProfileBookmark

How to pass parameters to an include

Hi.

I have a script as an include and it’s included on the page.
<script language=javascript src=”Focus.js”></script>

I would like to pass control name to that included script so that I could reuse the script on other forms.

The script looks like this.

var control = document.getElementById(“UserName”);

if( control != null )
{
control.focus();
}

Thanks,
Andy

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@AdamBrillAug 25.2003 — You should make a function. It would look like this:

function functionname(control){

if(control != null){

control.focus();

}

}

Then you would call the function like this:

functionname(document.getElementById("UserName"));

I hope that helps! ?
×

Success!

Help @awegrzyn 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.27,
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,
)...