Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

This is the friendlies forum ever! Javascript quick links help 2

Status
Not open for further replies.

isilkin

Technical User
Feb 12, 2008
27
0
0
US
Good Evening everyone!
It is so nice to see you all again. I am trying to change my career from graphic designer to computer repair tech and therefore building a site for myself.
I want to add a box on one side of the site with links to different sites or aticles and so on. But I want the fields to be populated dynamicaly from an external .js file.
Something simmilar to quick links menues that popular blogs and sites have. Often times in the box are the links to ads or menue elements.
If any one could tell me how to do that or point me in the right direction I would really appereciate.
What would be even cooler is a line of code that I can see.
Thank you so much.

Example something like on the right side here


Thank youuuuuu!
 
I'd recommend that you use server-side scripting (like PHP, ColdFusion or ASP) rather than client-side Javascript for dynamic menus. You can use them the same way, but they're search engine friendly and they display even if someone has JS turned off in their browser.

I use external files for the web pages I design to handle everything that's common to a number of pages, but I use either PHP or ASP for that.

Lee
 
Tahnk you, trollacious for your reply.
I agree with you PHP would be great the only problem is that I know next to nothing about it. Where is with javascript I know some basics and at least I know how to edit it.
I you could point me where I could get script for either one I would really appreciate it.

Also, this should be very simple to do because FLASH for example has an option in its UI to add dynamic text and link it to an external HTML ot TXT file.

Good example of these quick links is on



Thank you so much again.
 
Design your menu, then come back and show us your code.

I use JScript for my ASP scripting, pretty much the same as the Javascript I'd write for client side scripting.

Lee
 
thank you so much again. I will poist it tomorrow.
As I said the friendliest and most helpful forum ever
 
Good Evening, Everyone Again!
Pretty much I got to the point on my site where I would like to create these quick links. I could do them in HTML easily but since this box will be on every page, if I decide to update one link I will have to update every page.
That is why I wanted the link to be drawn dinamically from an external file.
here is a simple HTML layout that I will be using

Code:
<div id="links">
<ul><a href="" id="link1">link-text1</a></ul>
<ul><a href="" id="link2">link-text2</a></ul>
<ul><a href="" id="link3">link-text3</a></ul>
<ul><a href="" id="link4">link-text4</a></ul>
</div>

So, I would need help with populating "link-text" with the actual name of the link and blank space in "" to be the url of the link.

Any help will be gratly appreciated. If I am asking for too much just tell me I will agree with you :)
 
Use server-side includes, like I referred to in my first response.

What scripting language does your web host support? If it's PHP (and I realize this isn't the PHP forum), after changing the page extension to .php, use
Code:
include 'yourfilenamehere.php';
where you want to put the dynamic links. That puts them in a separate file that every page includes, and to change those links on every page, you just change the include file.

Lee
 
Thank you so much for you reply. I will have to google that include sintax and how to use it. My site does support php. So will every page tha has the links be renamed to php instead of html?
 
SSI's can be done in a standard HTML page as well, you need to make sure your host allows SSI's.

<virtual = xxx> is option if the files in a dir other than where the index page is.
 
Yes, if you use PHP you'll have to rename all your pages to end with .php. Max is correct that you can use server-side includes without using a scripting language (if your web host is set up for that), but you'll still have to change the page name extension to .shtm or .shtml.

You don't need to write any actual PHP to include another page, and the included page doesn't have to have a .php extension on it.
Code:
<?php
include 'myincludefile.htm';
?>
That said, I've done this kind of thing using client-side Javascript and document.write() statements in an external JS file, but I don't recommend it.

Lee
 
Yup, that's it exactly. That's what the last example I gave you was for, too. That's the way I handle pages on the websites I work on, if I can.

Lee
 
i will try this right now and as far as i understand the site has to be on the server in order to work. in other words php does not work on local machine. thanks everyone for helping me
 
You may have a web server available on your computer that you can install PHP to run on. Certain versions of Windows come with Internet Information Server (Win 2000 Pro and XP Pro both do, I believe). If not, you can download free web server software to run on your computer, and then install PHP (if the web server software doesn't come with it).

Here's a link to some free web server packages, and Apache is one of the most popular out there:


Lee
 
thank you again.
I used the include command and it worked like a charm.
Actually I can't believe it was this easy to make it work. PHP seem so integrate with HTML perfectly. I will remember this trick and use it many times in the future.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top