Computer problems,Computer help
*AX SOFT>>>Programming & Design

How in HTML or Javascript do you replace text in a table with different text?


I want a table say something like "Hello!" until someone presses a button, then I want the table to say "Goodbye!". How would I do this, could someone give me a sample of code, or a link to a website that says what to do?

Let's say you have a very simple table:

<table>
<tr>
<td id="TheMessage">Hello!</td>
</tr>
</table>

And then your button:

<input type="button" value="Say bye" onclick="sayBye()" />

Then your sayBye function would be like this:

<script type="text/javascript">
function sayBye() {
var td = document.getElementById( 'TheMessage' );
td.innerHTML = 'Goodbye!';
}
</script>

well this can vary. you can use Javascript and just run an if statement like this:
That is based off of whether at says logged in or not. doing on onclick you can run a function.
<script type-"text/javascript">
var iuser = document.getElementById("login");
if(iuser.innerHTML.match(/Logged in/i) {
document.getElementById("welcome").inn... ="Welcome"
}
else {
document.getElementById("welcome").inn... ="GoodBye"
}
</script>


The Function:
<a href="javascript:welcomegoodbye();">Say Goodbye </a>
<script type-"text/javascript">
function welcomegoodbye() {
document.getElementById("welcome").inn... ="GoodBye"
}
</script>

so there are a couple ways of doing it.

Tags
  General - Computers & Internet   Software   Security   Programming & Design   Facebook   Flickr   Google   MSN   MySpace
Related information
  • Php session issues?

    First, check your web server logs for error. Make sure php error reporting is on. Whenever you get a blank page, you've got an error. Are you calling session_start(); at the top of each o...

  • RefactorIT refactoring Java Source Code?

    Refactoring code is something a human should do using an IDE. One analysis tool I enjoy is PMD. It runs a bunch of (configurable and extendable) rules and reports a list of things it sees. Sev...

  • How do i get a FONT like this in this image?

    Here is the website to download that font. ...

  • What is the font IMVU used for their logo?

    Baubau and Pico White are in that style. ...

  • How can I re-install windows vista again?

    pop that Vista disc in the cd tray and reboot..keep tapping the F2 key untill the black and white screen appears,now select install windows....windows will ask you if you want to keep the old parti...

  • Could you pls help me about html??

    i'm also has that same problem..

    ...
  • Hey!!!Are you a programmer ?? Can you help me to explain this Program in C-language? (below)? please !!?

    Here's the explanation: ------------------------- #include <stdio.h> ------------------------- This line tells us to INCLUDE a header file containing standard input output function...

  • I really need your help to assist me to sort out the errors i get on my program!?

    That is going to be quite difficult. If you are still stuck with your project assignment may be you can contact a programming expert live at website like ...

  •  

    Categories--Copyright/IP Policy--Contact Webmaster