Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Expanding Boxes

Status
Not open for further replies.

Kizza1

Programmer
Joined
Nov 26, 2006
Messages
1
Location
GB
Hi, I'll try and explain this as best as I can, its a little thing which I got someone to make and then I made some of my own changes and it didn't work. (I know almost nothing about javascript)

I have 3 div's and in one div (id=fs2) there is a textarea which is 3 rows big. The aim is when I click each div the others get smaller and the one you clicked on gets bigger. The problem was that it squashed all of the writing/text together and didn't work (mostly because of a textarea that was 15 rows big.) So I decided to change the code to make the textarea be 3 rows, if fs2 is selected it is 15.

The code in <head> is:
<script language="javascript">
function init(){
document.getElementById("fs1").style.height="30px";
document.getElementById("fs2").style.height="30px";
document.getElementById("fs3").style.height="30px";
document.getElementbyId("tx1").rows="3";
}

document.onLoad=init;

function expand(id){
document.getElementById("fs1").style.height="30px";
document.getElementById("fs2").style.height="30px";
document.getElementbyId("tx1").rows="3";
document.getElementById("fs3").style.height="30px";
document.getElementById(id).style.height="300px";
if (id = "fs2")
{
document.getElementById("tx1").rows="15"
}

</script>

I added in the .rows lines and the if statement (not sure if correct.) I've named the textarea tx1 and I want it so that when you click on fs2, the textarea gets 15 rows. If it isn't selected, then it has 3.

The code for each div is:
<div align="center" onclick="Javascript:expand('fs1');" id="fs1">

For the other two it changes to fs2,fs3.
The textarea code= <textarea id="tx1" rows="3" name="original" cols="67"></textarea>

I hope you understand what I mean, thanks.
 
I see this error right away:
Code:
if (id = "fs2")
Should be:
Code:
if (id == "fs2")

VBSlammer
redinvader3walking.gif

"You just have to know which screws to turn." - Professor Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top