Click to See Complete Forum and Search --> : Swapping text in a web page


reillyc2
03-26-2003, 06:07 AM
I'm creating a web page and I'd like to make a textbox whose content would change when a user clicks a button without loading a new page.

Basically I want to put long articles into the website but avoid having to scroll.
- an article appears in a text box on the page
- when a user reads to the end they click a "next" button and
the text in the text box changes without reloading the whole
page i.e. only the info in the box changes

I don't really want to use frames.

Any suggestions on how I could do this?

gil davis
03-26-2003, 06:22 AM
There are no file handling capabilities in Javascript. Your only choice is to change the source parameter of an inline frame.

pyro
03-26-2003, 07:15 AM
Please view this file: http://www.infinitypages.com/research/clientsidedivinclude.htm

IxxI
03-26-2003, 07:20 AM
I suggest that you use a div box. You can position it where you like on your page and then have the text in it change depending on which button you pressed. Say you had a div called "maindiv" and two or three buttons, then you could control the content using something like this:


<HTML>
<HEAD>
<script>

var starttext="Some text you want to be there to start with"
var onetext="Text you want to show if they click button1"
var twotext="Text people see if they click button 2"

function changediv(txt)
{
document.getElementById("maindiv").innerHTML = txt;
}
</script>
</head>

<body onload="changediv(starttext)">

<form>
<input type="button" name="button1" value="button1" onClick="changediv(onetext)">
<input type="button" name="button2" value="button2" onClick="changediv(twotext)">
</form>
<div id="maindiv">
</div>
</body>
</html>


Hope this helps..

IxxI

IxxI
03-26-2003, 07:22 AM
Sorry Pyro, we posted at the same time!!

IxxI