Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rating: Thread Rating: 1 votes, 4.00 average. Display Modes
Old 01-13-2002, 01:16 PM   #1
Member (9 bit)
 
Join Date: Dec 2001
Location: US
Posts: 468
Send a message via AIM to wilbasket23 Send a message via Yahoo to wilbasket23
Angry Fire need help on function "getelementbyID" and javascript

i got some question about the "elementbyID" function. What does it use for? Can anyone give me an example explain this function!!!! Also, i wrote a javascript and save as .js file. How can i include this file to my html page. The problem that i am having right now is that i have 20 html pages. I want to use and include the .js file into every html page. I don't want to type or cut/paste the code into every html pages. Isn't there a way that i can include the .js file which contains all the necessary coding and insert into every html pages that i want to use the javascript. Can anyone help me with this!!!!
wilbasket23 is offline   Reply With Quote
Old 01-13-2002, 01:47 PM   #2
Member (10 bit)
 
Join Date: Jan 2001
Location: Birmingham, UK.
Posts: 553
Send a message via Yahoo to dj4uk
There is indeed a way to include the code in your pages.

<script language="javascript" src="example.js" type="text/javascript">
</script>

Substituting example.js for a file with the javascript you want to include in each page.
dj4uk is offline   Reply With Quote
Old 01-13-2002, 01:49 PM   #3
Member (13 bit)
 
DrZaius's Avatar
 
Join Date: Jul 2000
Location: Fullerton, CA
Posts: 7,030
Hi wilbasket23,

You include a script into an HTML file but adding this:
Code:
&ltSCRIPT SRC="myscript.js"&gt&lt/SCRIPT&gt
Where "myscript.js" is the name of your script.

Sorry, I don't know much about the ElementByID. I think it's used to call specific form elements on the page. Hope that helps.
__________________
"A witty saying proves nothing." - Voltaire
DrZaius is offline   Reply With Quote
Old 01-16-2002, 07:50 PM   #4
Member (9 bit)
 
Join Date: Dec 1999
Location: Midland, NC, USA
Posts: 292
The above two examples will get the script included.
getElementbyID is used to retrieve an element from a page so you can process it.
For example, say you have a couple of input boxes, one where you have id="InputOne", the other you have id="InputTwo" in their attributes. You want to copy whatever the user types into InputOne over to InputTwo when the user clicks on a button on the page.

In the definition of the button, you could include onclick="CopyOver();". This would cause the CopyOver function to run when the button is clicked.

The CopyOver function would include the statement:
Code:
document.getElementbyID("InputTwo").value=document.getElementbyID.("InputOne").value;
The key is to identify the elements (id="InputOne").
As an alternative, you could give the elements names by using name="InputOne", etc., and retrieve them by using getElementsByName. Note that, when retrieving by name, it's "getElements" (plural) and when retrieving by id it's "getElement" (singular).
UncaDanno is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 07:50 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2