473,395 Members | 2,467 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Any one know how to use a duplicate javascript in the same page?

Amy
Hi using duplicate javascripts on the same page never work for me due
to the same property fields on the page twice. Anyone know how to get
around this? Thanks.

Oct 31 '06 #1
4 1478

Amy wrote:
Hi using duplicate javascripts on the same page never work for me due
to the same property fields on the page twice. Anyone know how to get
around this? Thanks.
Can you show an example, Amy?

Val Polyakh

Oct 31 '06 #2
Amy
Gosh, most of them really. Lets say I have two identical javascripts. I
call both of them with an onload command. <script
type="text/javascript">window.onload=function(){image1();imag e2();}</script>Thing
is they both have identical other areas in the body section.

<a href="#" id="link" target="_blank"><img id="img" title="title"
border="0"></a>
<a href="#" id="link" target="_blank"><img id="img" title="title"
border="0"></a>

Since there are two identical slots to fill, the script doesn't know
what to do, and only one works. How to get around this problem?
Thankyou Amy

sc********@gmail.com wrote:
Amy wrote:
Hi using duplicate javascripts on the same page never work for me due
to the same property fields on the page twice. Anyone know how to get
around this? Thanks.

Can you show an example, Amy?

Val Polyakh
Oct 31 '06 #3
In HTML, is you use the ID attribute on a tag, it needs to be unique.
You cannot have more than 1 element with the same ID. Here you have two
elements with id='img', which is not valid HTML. Plus, if you use
javascript's getElementById() command, it can only return 1 (I am
guessing the first one it finds).

Try using different IDs on your images and calling them appropriately.

On Oct 31, 8:32 am, "Amy" <rianna...@aol.comwrote:
Gosh, most of them really. Lets say I have two identical javascripts. I
call both of them with an onload command. <script
type="text/javascript">window.onload=function(){image1();imag e2();}</script>Thing
is they both have identical other areas in the body section.

<a href="#" id="link" target="_blank"><img id="img" title="title"
border="0"></a>
<a href="#" id="link" target="_blank"><img id="img" title="title"
border="0"></a>

Since there are two identical slots to fill, the script doesn't know
what to do, and only one works. How to get around this problem?
Thankyou Amy

scriptg...@gmail.com wrote:
Amy wrote:
Hi using duplicate javascripts on the same page never work for me due
to the same property fields on the page twice. Anyone know how to get
around this? Thanks.
Can you show an example, Amy?
Val Polyakh
Oct 31 '06 #4
ASM
Amy a écrit :
Gosh, most of them really. Lets say I have two identical javascripts. I
call both of them with an onload command. <script
type="text/javascript">window.onload=function(){image1();imag e2();}</script>Thing
is they both have identical other areas in the body section.
if you have two time same function or same mane for 2 functions
(i.e image1() ) only the second will fire
(the 1st is scratched by the 2nd)
<a href="#" id="link" target="_blank"><img id="img" title="title"
border="0"></a>
<a href="#" id="link" target="_blank"><img id="img" title="title"
border="0"></a>

Since there are two identical slots to fill, the script doesn't know
what to do, and only one works. How to get around this problem?
Thankyou Amy
Having 2 elements with same id is forbidden !

Or do you mean that
image1() write 1st link
image2() write 2nd link (exactly same as 1st)
? ? ?

Nothing very clear about what you try to do ...

have links with different ids
and function 1 for link 1 and function 2 for link 2
Oct 31 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Randell D. | last post by:
Folks, I'm a newbie when it comes to JavaScript and whenever I visit a website curiosity sometimes get's the better of me and I'll inspect some of their code - It teaches me new things (either...
6
by: nick4soup | last post by:
I have read the CGI FAQ 'How can I avoid users hitting "submit" twice' (on http://www.htmlhelp.org/faq/cgifaq.3.html#19 ) which essentially says you have to detect it at the server, using a...
5
by: Darrel | last post by:
I have a web form that inserts a record into a DB. This function is called from the button_click subroutine. After the record is inserted, I show/hide some different panels and let the page...
10
by: Adam Clauss | last post by:
I have a page containing a list box. This list may contain duplicate items - in which the ORDER is important. ex: a b b a is significant as compared to: b
2
by: hemant.singh | last post by:
I am stuck with strange JS issue My product gives user to show some images(which track mouseover) on page by embedding script like <script src=http://domain.com/GetDynamicJS?domagic=1>...
6
by: planetthoughtful | last post by:
Hi All, I have a C# ASP.NET page that submits back to itself to insert details from a form into a database table. When / if the user refreshes the page (and gets the standard warning that POST...
1
by: KoRnDragon | last post by:
I need a Javascript function that will display X random images on a page that also doesn't display the same image twice. Bonus points if it grabs the max array from the folder and sets it. Even...
6
by: Oleg Konovalov | last post by:
Hi, I have a Java/JavaScript GUI application where I perform a lot of long DB operations , which takes 5-60 secs to perform. Sometimes user double-clicks the button or just gets impatient and...
3
dmjpro
by: dmjpro | last post by:
Today i encountered a typical thing. So far what i knew that JavaScript had a scope inside a function but it was not there. I think in newer version of JavaScript it is introduced, in older version...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.