Path: csiph.com!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Ben Bacarisse Newsgroups: comp.lang.javascript Subject: Re: simple question Date: Sun, 12 Nov 2017 14:22:38 +0000 Organization: A noiseless patient Spider Lines: 63 Message-ID: <87375jwp8x.fsf@bsb.me.uk> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="6990cf73bed5c4f34de9a73f4d41615b"; logging-data="2646"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX197rveUhruvAsmOfJjDTzLfkghM4AM0qpA=" Cancel-Lock: sha1:WMZ8qQUNDZGgrsvukOHmnTr65Oc= sha1:HJ1kmysmu5TS6UN4kNn/b00cneY= X-BSB-Auth: 1.b8fe3d03ba16f64d2fa3.20171112142238GMT.87375jwp8x.fsf@bsb.me.uk Xref: csiph.com comp.lang.javascript:34319 super70s writes: > > > > > > > > > > > > > Hi I have a simple question, if I had two of the above scripts on the > same page, how can I distinguish one from the other? You can't, at least not in the way I think you mean. I think you want to be able to select two messages from two different arrays. To do that you should make the message array a parameter to your function. (Personally, I'd do things a little differently but I want to suggest minimal changes.) So you have one script element with function writeTip(msgs) { document.write(msgs[new Date().getDate()]; } and then call it with different arrays from two other script elements (I'll show only one): No doubt I have lots of typos since this has not been machine checked. Note how I have avoided variables where possible. If you do need them you should learn how to avoid them being "global". -- Ben.