Jul 27, 2008

Expanding Link

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > HTML, XML etc..
Pages: 1, 2

free web hosting

Expanding Link

Amezis
Wee... Another question:
How can I make that clicking on a specific link expand to something?
Well... Here's an example:

I have a list with the 5 best sites:
Site 1
{more info}
site 2
{more info}
etc.
Clicking on {more info} for site 1, will show a description below the link, and now, site 2 will be below the description.

I hope you understand my question tongue.gif

Reply

round
nope, not really. using what php? cause that i can help you with.
round

Reply

Amezis
I don't know about any php coding, but I could try... Isn't there a html code for that? Like dropdown-menus?

Reply

Amezis
Heh I found a good example... You can hide and show forums in trap17. I need something like that, but default is set as hide.

Reply

no9t9
if i understand correctly, you are trying to offer more information in something like an information box when the user clicks the link.

you can do this in many different ways.

Javascript method.
CODE

<script>
function display(idx) {
var text=new Array;
text[1]="link 1 description";
text[2]="link 2 description";
if (document.all) document.all['linktext'].innerHTML=text[idx];
else if (document.layers) document.layers['linktext'].innerHTML=text[idx];
else document.getElementById('linktext').innerHTML=text[idx]; }
</script>

<a href=# onclick="display(1);">link1</a>
<a href=# onclick="display(2);">link2</a>
<span id=linktext>Link Description</span>


modify the descriptions or add more depending on the number of links you want. example: text[3]="another description"; and so on.

the if statement is there so that your code will work for all popular browsers.

document.all = IE
document.layers = Netscape/Opera
document.getElementId = Firefox

when calling the display function, you pass the text number. In this case, when you pick display(1); you are asking to display text[1] or the message "link 1 description".

the message will show up in between the <span> tags. Whatever you put between the <span> tags will show up when the page is loaded.

 

 

 


Reply

Amezis
Well, looks nice... I know there are other codes for this! post more... I will hand pick the code which is best smile.gif Maybe plus in your reputation too smile.gif

Reply

no9t9
how about this script. I think this is closer to what you want.
Basically, you can create as many boxes as you like and put the descriptions in the boxes (DIV tags).

<script>
function expand(divID) {

var layer="document.all", style=".style";

if (document.all) layer="document.all";
else if (document.layers) { layer="document.layers"; style=""; }
else layer="dom";

if (layer=="dom") {
if (document.getElementById(divID).style.height!="1px")
document.getElementById(divID).style.height="1px";
else
document.getElementById(divID).style.height="100px"; }
else {
if (eval(layer+"[divID]"+style).height!="1px")
eval(layer+"[divID]"+style).height="1px";
else
eval(layer+"[divID]"+style).height="100px"; } }
</script>

<a href=# onclick="expand('box1');">expand/collapse</a>
<div id="box1" style="height:100px;border:1px solid #000000;overflow:auto">Your description 1.</div>
<a href=# onclick="expand('box2');">expand/collapse</a>
<div id="box2" style="height:100px;border:1px solid #000000;overflow:auto">Your description 2.</div>

I put expand/collapse there but you can make it look better by putting an up/down image there instead. You can also change the image to up or down depending on whether the box is expanded or collapsed.

Reply

no9t9
Forgot the code tags. Oh well, no edit button.

Also want to note that it should work for all popular browsers like firefox, IE, netscape, opera. but i didn't test the code.

just copy it and save it as an html and run it in your browser to see the results.

Reply

Amezis
Well, there is 2 things now.

Firstly: No9t9, could you make that default is HIDDEN, not shown.
Secondly: This is for a long list, with alot of images. So could you make it to load when you click on the "expand"-link, so the whole page don't take ages to load?

Reply

no9t9
well first, to make it hidden you just switch the numbers on the height value. where you see 100px change it to 1px and where you see 1px change it to 100px. It's really easy. Do you have any idea how to program Javascript? You should learn if you are going to be developing webpages. That way you can edit code that you find to make it suitable for your needs.

As for loading the images after clicking the button, the logic is in the first example I made. You have to use the innerHTML property. the innerHTML property physically alters the HTML dynamically. In this case, I would change the contents of the box with the innerHTML property to <img src="picture.jpg"> that would load the image.

CODE

<script>
function expand(divID) {

var layer="document.all", style=".style";

if (document.all) layer="document.all";
else if (document.layers) { layer="document.layers"; style=""; }
else layer="dom";

if (layer=="dom") {
if (document.getElementById(divID).style.height!="100px")
document.getElementById(divID).style.height="100px";
else
document.getElementById(divID).style.height="1px"; }
else {
if (eval(layer+"[divID]"+style).height!="100px") {
eval(layer+"[divID]"+style).height="100px";
eval(layer+"[divID]").innerHTML="<img src='picture.jpg'>Your description"; }  //added this line
else
eval(layer+"[divID]"+style).height="1px"; } }
</script>

<a href=# onclick="expand('box1');">expand/collapse</a>
<div id="box1" style="height:1px;border:1px solid #000000;overflow:auto">Your description 1.</div>
<a href=# onclick="expand('box2');">expand/collapse</a>
<div id="box2" style="height:1px;border:1px solid #000000;overflow:auto">Your description 2.</div>

Reply

Latest Entries

Amezis
Lol yeah I think I have to learn Javascript tongue.gif

Reply

no9t9
it works for me. I only included the Internet Explorer code for the picture part. Did you copy it correctly? Also, the code only displays one picture. there are more modifications needed in order to get more pictures.

seriously, if you know absolutely nothing about javascript it will be very hard to provide you with exactly what you need. I think you should learn so you can modify it to suit your needs. Otherwise, you will always be back with changes.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Pages: 1, 2
Similar Topics

Keywords : expanding, link

  1. Creating Link In Html - Help Me With This!
    (5)
  2. Refresh Main Window By Clicking Link In Popup?
    (2)
    This is another refresh problem question. The project I'm doing uses tons of frames (I know,
    some of you will probably advise me not to use frames) and I'm having problems with refreshing
    the target frames. The problem is, I have a main page (main.html) that is a popup (so that I
    don't see the address bar and the other toolbar bits in my browser) and there are links in that
    page that when clicked also pops up a page. What I don't know is how to refresh the main page
    using a link in the other popup page. I've tried using this but this only works f....
  3. Populating A Form From A Link
    (5)
    I have an online application Form that multiple groups use from their own webpages. I would like the
    form to automatically populate a couple fields depending on which group's site it's clicked
    from......... I think there is a way to populate a form just by adding stuff to the link, but I
    don't know how and I can't find any information on how online (not really sure what to
    search)......... anyone know? I want a combo-box and a text field automatically populated with
    information depending on the link that's clicked. I honestly don't know if this i....
  4. Making A Refresh Link On Your Website.
    refresh local webpage (16)
    /smile.gif' border='0' style='vertical-align:middle' alt='smile.gif' /> post it on ur website
    CODE <a href="javascript:this.location.reload();" style="color:
    #000000; font-weight: normal">refresh</a> It can refresh local webpage. U
    can add it at ur forum so that each topic u are reading can be refresh easily. If ur website
    return to homepage after pressing I.E. refresh button, then u must need this coding. /cool.gif'
    border='0' style='vertical-align:middle' alt='cool.gif' /> Beacus visitors only w....
  5. Link To Create Desktop Shortcut?
    (5)
    Is there a way to make a link that actually creates a desktop shortcut? I have a page that gives
    links to files on our intranet but I know of people who try and make shortcuts for these files. It
    would be nice if I could put a link next to the link for the file that would make a shortcut. Use
    a more descriptive topic title next time. ....
  6. Dropdown Menus Links
    IDK how to make them link (3)
    Ok its a big problem to me, i need to make my drop down menus options link to a web page. I know i
    can do it with a button, and i can get that to work but i need/want to have it link as soon as the
    option is selected........How do i do that?....
  7. Link Colour
    (5)
    Hey all, i dont know how easy this is to do or whether it can be done just using HTML or whatever.
    Basically i have 2 seperate navigation bars top nav bar is the parent navigation bar. when you
    hover over any of the entries in this parent bar it dynamically updates the second nav bar. what i
    ideally want is to highlight the parent link in black when i move the mouse over it BUT stay black
    until i select/ hover over another parent link. does that make sense? ....
  8. A Good Space For Learn Html
    web site link (5)
    Hi i find this web site you can learn html lan very fast and very easy woow i found it many
    tutorials go http://www.w3schools.com/ its really good website /rolleyes.gif' border='0'
    style='vertical-align:middle' alt='rolleyes.gif' /> ....
  9. Table/cell Link?
    (10)
    Well, I actually don't know what it is. But I need a code where you can click everywhere on the
    table, not only on the text/image.....
  10. Fade Link Color
    (4)
    hi, how do you make the linkcolor fade to another color when pointing your cursor to the link?
    It's a rather short description of my question, but i hope it's clear /cool.gif'
    border='0' style='vertical-align:middle' alt='cool.gif' /> . More tips and tricks are welcome.......

    1. Looking for expanding, link

Searching Video's for expanding, link
advertisement



Expanding Link



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE