|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread |
Rating:
|
Display Modes |
|
|
#1 |
|
Member (9 bit)
|
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!!!!
|
|
|
|
|
|
#2 |
|
Member (10 bit)
|
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. |
|
|
|
|
|
#3 |
|
Member (13 bit)
Join Date: Jul 2000
Location: Fullerton, CA
Posts: 7,030
|
Hi wilbasket23,
You include a script into an HTML file but adding this: Code:
<SCRIPT SRC="myscript.js"></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 |
|
|
|
|
|
#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;
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). |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|