• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Show text onclick

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry if it is something trivial.
I need to program displaying the text when the link is clicked. For example I need to have a bar:
Algorithm | Contact us | .... | ....
When I click Algorithm it should show the text with algorithm description right below the bar, for Contact us it should show e-mail address, etc. It should not be linkes to other html files.
It should be purely HTML+JavaScrip, nothing on the server side.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What have you written so far?
 
viktor boulg
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a piece of HTML code, but it does not allow me to post it.
 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, unfortunately you can't post HTML bits, but you might consider creating a text document and linking to it.

The gist of what you want to do is relatively simple. You want to use onclick event handlers for each link in your menu, pointing to a function that will determine which event was triggered and then retrieving the correct text for that function. You can do this via hidden div elements on your page (e.g. having hidden elements that already contain text suddenly appear), or retrieving the text using the XMLHttpRequest object (Ajax, in other words). Either method is relatively simple to implement, and if you use a JavaScript library like jQuery it's trivial.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
replace the o in onclick with &111;

Eric
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Eric Pascarello:
replace the o in onclick with &111;


Correction: o
[ December 01, 2008: Message edited by: Bear Bibeault ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic