Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more

Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Web Design Forum > HTML / CSS
User Name
Password

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 08-13-2006, 06:55 PM   #1 (permalink)
krato
Junior Member
 
Join Date: Aug 2006
Posts: 1
Unhappy JavaScript expand/contract textarea ~please help

Hi, i would really appreciate a little help with my JavaScript, i've only just started learning it and i'm stuck. I've gone as far as to get the following script working but i need some adjustments that i just can't seem to get working. Please bear in mind i'm a newbie please be gentle with me

I'm trying to make a textarea expand and contract when pressing buttons below the textarea. I've managed to get this to work but i need to change my IF statements, so the textarea can only expands when its less than 40lines long, and can only contract when its more than 10 lines long.

I think i also need an else statment incase it doesn't fit into either of the if statements but i might be wrong about that - i don't know. Either way i can't get it to work i've commented out the parts that i can't get to work, the rest seems fine. If someone could please help me i'd be really greatfull

As well as the code below i also have a test page to show it working. its at krato.co.uk/admin/news/test .html

This is what i have:

Code:
<html> <head> <script type="text/javascript"> function resize(id, type) { var txtId = document.getElementById(id); //if (type == 'expand' && txtId.rows < 40){ //i would like that but can't get it to work :( if (type == 'expand') { var newRows = txtId.rows + 10; } //if (type == 'contract' && txtId.rows > 10){ //same as above :( else if (type == 'contract') { var newRows = txtId.rows - 10; } //i think i need an else, incase it doesnt fit into the above IF's, i cant get it to work though //else { // var newRows = txtId.rows; //} txtId.rows = newRows; } </script> </head> <body> <!-- textarea "tags"--> <textarea name="tags" cols="65" rows="10" id="tags"></textarea> <br /> <!-- expand and contract buttons for textarea "tags" --> <input type="button" name="expand1" onClick="resize('tags', 'expand')" value="+"> <input type="button" name="contract1" onClick="resize('tags', 'contract')" value="-"> <br><br> <!-- textarea "body"--> <textarea name="body" cols="65" rows="10" id="body"></textarea> <br /> <!-- expand and contract buttons for textarea "body" --> <input type="button" name="expand" onClick="resize('body', 'expand')" value="+"> <input type="button" name="contract" onClick="resize('body', 'contract')" value="-"> </body> </html>

Thankyou

Ryan

Last edited by krato : 08-13-2006 at 07:12 PM.
krato is offline   Reply With Quote
Sponsored Links
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Points Per Thread View: 1.00
Points Per Thread: 11.00
Points Per Reply: 5.00



» Sponsors

» Links

» Affiliates
Web Hosting
Marketing Find
Merchant Select
SiteMap Builder
Host Compare
Dedicated Servers

» Links

» Sports Network
Paintball Forum
Football Forum
Hockey Forum
Golf Forum
Boxing Forum
Lacrosse Forum
Baseball Forum
SnowBoarding Forum
Soccer Forum
MMA Forum


All times are GMT -4. The time now is 12:29 PM.



LinkBacks Enabled by vBSEO 3.0.0 RC8
Webmaster Forums