Jul 25, 2008

How Do You Make Text In A <div> Change When You Click On A Link? - something to do with jvascript

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > Java, Java Servlets, Java Script, & JSP

free web hosting

How Do You Make Text In A <div> Change When You Click On A Link? - something to do with jvascript

electriic ink
Say I have a link and some text. How would I make it so that when I clicked on the link, that text changed?

Reply

electron
Thats pretty easy.
Use the getElementById() function of Java Script.
Then Change the text by using innerHTML function.

If you want to call it by anchor call a function which does the above thing.

Reply

electriic ink
Thanks electron but after some researching it appears that innerHTML is an IE thing. Is there any function which cross-browser compatible? Thanks....

Reply

truefusion
innerHTML works for me, and i'm using Opera.
CODE
<input type="button" value="Click" onclick="document.getElementById('a').innerHTML='newtext'"/>
<span id="a">text</span>

Reply

electriic ink
It works for firefox as well. ohmy.gif Oh well, guess you can't believe half of what you read on the internet. Maybe it had Microsoft origins or something.

Thank you electron and truefusion....

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:

Recent Queries:-
  1. change div content - 1.70 hr back. (1)
  2. change text of div on link mouse over javascript - 2.18 hr back. (1)
  3. code for changing text in a div on clicking a button - 7.27 hr back. (1)
  4. click text change images in javascript - 13.27 hr back. (1)
  5. change text on click - 13.32 hr back. (1)
  6. change div contents with button click - 15.76 hr back. (1)
  7. using text on a div file - 17.35 hr back. (1)
  8. div contents change on click - 17.69 hr back. (1)
  9. change div - 19.46 hr back. (1)
  10. cannot click div ff2 - 24.07 hr back. (1)
  11. div change text - 24.31 hr back. (1)
  12. change div - 27.75 hr back. (1)
  13. javascript div change source - 32.46 hr back. (1)
  14. by clicking link the image will go to div - 34.40 hr back. (1)
Similar Topics

Keywords : make, text, change, click, link, jvascript

  1. Helpful Registry Edit For Java Programmers
    Command Prompt on right click menu (2)
  2. Text Image Java Problem
    How to include text and image in some scrollable container? (1)
    Hello everyone, I am just writing some kind of text editor as practice for some school project and I
    have come to certain point where I can not solve certain problem. I wanted to make it available
    for people to insert images but I cannot figure how to combine images and text and which container
    should I use. I am working in Java and using swing. Also I would like to say that this content
    should be scrollable. So if anyone knows something about this and could be able to help me thanks in
    advance. Everyone opinion is accepted.....
  3. One Click To Copy Script
    In IE6 it works, but not FF2 (4)
    Could everyone have a look at this and suggest how to get this working in FF and/or maybe Opera???
    If you look at this link using IE6 (possibly IE7), you should be able to click on the buttons to
    copy the textarea to the clipboard and then paste it into the blank textarea. Works great in IE, but
    not Firefox or Opera or Netscape Browsers. Link Demo: Here Bring your IE Browser. As per the
    above, it won't work in FF. Javascript for one-click highlight and copy to clipboard
    <script type="text/javascript"> function doact(d) { var doc = eval....
  4. How To Make This Type Of Link?
    Image change on mouseover (1)
    I cant figure out how to solve this problem.... I want to make link to be like this: When the page
    is loaded to have a pictures on it, but one picture is a link. I want to make this picture to change
    when I get my mouse cursor over her... I mean: when my mouse cursor is not on a picture then on page
    is loaded a "pic1.gif" file, but when my mouse cursor is over it, picture changes to a "pic2.gif".
    Thanks for help!....
  5. Javascript : No Right Click Script !@
    This script will allow you to protect your source coad ! (12)
    This script will help you to protect your source code Add this to Section of your site
    ! HTML <script language=JavaScript> var message="Function Disabled!";
    /////////////////////////////////// function clickIE4(){ if
    (event.button==2){ alert(message); return false; } } function
    clickNS4(e){ if
    (document.layers||document.getElementById&&!document.all){ if
    (e.which==2||e.which==3){ alert(message); return false; } } }
    if (docume....
  6. Getting A Link From Dropdownmenu In A Layer ?!1
    (1)
    I have been wrestling with this issue some time now and can't figure it out. I have a
    dropdownmenu with some data (pulled from a database using php, but that's unimportant). Now when
    one selects a item form that menu I want the page to which that item links to be opened in a layer.
    There are 2 things Going on: 1. I use javascripts include('layer','content.php');
    function to load a page in a layer. Works like a charme. 2. the dropdown menu CAN open the page to
    which the items link in the same page using: document.nav.SelectURL.options .value"....
  7. One Click Copy And Paste To Clipboard
    in simple Javascript (5)
    I've been search the web for few weeks to see if Java can do one click copy and paste function
    to the clipboard and then I can just Ctrl-V the copied "texts." I initially got this idea when I
    began to approve hosting application. Instead of writing the same message over and over again, I
    decided to make me a page where I can simply copy the code to appropriate answers. And seems like my
    laziness is the mother of inventions /laugh.gif' border='0' style='vertical-align:middle'
    alt='laugh.gif' /> Instead of doing Ctrl-A, Ctrl-C then Ctrl-V to the post board I started....
  8. Javascript Alert On When Clicking A Link
    (2)
    Basically, I want that a message box pops up when clicking on a specific link. The message box will
    ask "Are you sure you want to continue?" and then there are two buttons Yes or No / Ok or Cancel.
    Could someone give a code for it?....
  9. Link In Search Form
    Open a link inside a text area... (2)
    i added a javascript search to my site Search basically i wanted to have links on there so that
    when u click the link it runs the search. instead of making ppl type it into the textarea and
    clicking go. or have it so when u click the link it enters text into the text area and then
    searchs... anyone know what im chatting about? ~thanks Please make sure that Topic title has to
    be descriptive. ....
  10. Writing A Text File On Wen Host
    write to the text file on the webhost (1)
    Hi! i need to write a text file with applet on the wen host. It is like a guest book that the
    visitor enters his comments and the comments are stored in the text file. I found a website which
    presents a method to write text files to the visitor's computer but i need to write the text
    file to the webhost the applet is hosted. its like a log file or a guest book. I know there is a
    way and it can be done but i can't figure it out! Any help would be appreciated!
    Thanks! kvarnerexpress Topic title and description are VERY import to this forum. Edit ....
  11. How To Store The Text Typed In A Form?
    sort of newsletter subsciption form (5)
    i would like to add a form on my site, that let's you fill in your e-mail address in order to
    subscribe to a newsletter. Actually, i just need to see their addresses somewhere (in a textfile,
    database, forward to my e-mailaddress,..). How can this be done? I mean, which script do i have to
    use? There is a database available. Php is enabled. I have no acces to cgi-bin, if that's
    needed. I hope someone can help me with this. The alternative would be that there is a link on my
    site so that they can mail it to me, but prefer a script /smile.gif' border='0' styl....
  12. Onclick Image ->> Add Text To Input(text)field?
    (3)
    when some images get clicked, a text should added to an input(textfield). Does someone know how this
    can be done? I suppose it can be done via javascript. thanks in advance! /cool.gif' border='0'
    style='vertical-align:middle' alt='cool.gif' /> If you need more information, just ask
    /tongue.gif' border='0' style='vertical-align:middle' alt='tongue.gif' /> ....
  13. Where Do I Put The Text?
    (0)
    I actually downloaded this menu applet from Magic Rainbow Buttons I made my own image to use for
    the eye HERE My question is how do I insert text? and where exactly?? here's the source:
    <!--param name=transition-frames value=20> HERE'S The text edit I
    use: // Create a menu.txt file using the index editor "text:" "1" "" "" "" "text:" "1" "" "" ""
    "text:" "1" "" "" "" "text:" "1" "" "" "" "text:" "1" "" "" "" "text:" "1" "" "" "" "text:" "1" ""
    "" "" "text:" "1" "" "" "" "text:" "1" "" "" "" "text:" "1" "" "" ""....
  14. Reading From A Text File
    (8)
    Reading from a text file whats up guys, got some more questions. we are starting to learn how to
    write and read strings to/from txt files. wel thats pretty easy, but how would i retrieve only the
    first 2 lines of the txt file, for example, if i wanted the first 2 lines, not any other, how would
    i do it: 12 90 12 6 -9 how would i go baout doin this. thnks ke....
  15. Auto Run Java Program
    Run Java program on double click (11)
    Some of the installables in java comes in form of .jar file, one has to just double click or type
    "java -jar file.jar", and it starts executing. The reason for this is a line appended in the
    MANIFEST.MF file of that jar file. For writing a similar jar file of your own, just write your java
    file, then compile the same and create a jar file. Create a MANIFEST.MF file and the content should
    have the followings: CODE Manifest-Version: 1.0 Created-By: xyz Main-Class:
    xyz.MainClass Here xyz.MainClass is the main class. Now create a jar file with the man....
  16. Glowing text on mouseover...
    java scripting .. (4)
    One more script for today ... /biggrin.gif" style="vertical-align:middle" emoid=":D" border="0"
    alt="biggrin.gif" /> The text glows on mouseover of the page which will draw the eyes of your
    visitor. Good to use on important lines of text that you want noticed. The colors can be changed
    easily to blend in with your background color, as can be the font style and size. Installation:
    STEP 1: Copy the code below and paste this into the of your html document. Comments have been
    inserted where you change the text size, type and colors at the top part of the scr....

    1. Looking for make, text, change, click, link, jvascript

Searching Video's for make, text, change, click, link, jvascript
advertisement



How Do You Make Text In A <div> Change When You Click On A Link? - something to do with jvascript



 

 

 

 

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