/    Sign up×
Community /Pin to ProfileBookmark

Alter height of a textarea.

Hey. I am trying to input someting to my site which I’ve seen on other forums, like these – which allow you to increase the size of a text area and decrease it. I found a script that does this, and followed what it said to do – but it’s just not working. Can you see what I missed?

I have a ‘count.js’ which I have in my <head> tags, which loads fine as other code from that works ok.

The other annoying thing is because the href is “#” it means everytime it’s clicked it throws it back up to the top of the page so you have to scroll back down, I don’t see that happening on the other sites I saw it on – maybe that’s just because the code isn’t working though.

count.js contains:

[code]
function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long…trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update ‘characters left’ counter.
else
countfield.value = maxlimit – field.value.length;
}

function alter_box_height(boxid, pixelvalue)
{
var box = fetch_object(boxid);
var boxheight = parseInt(box.style.height);
var newheight = boxheight + pixelvalue;
if (newheight > 0)
{
box.style.height = newheight + “px”;
}
return false;
}
[/code]

On our HTML form we have:

[code]
<tr>
<th class=”intro”><label>Query:</label></th>
<td class=”forminput”><textarea name=”COMMENTS” wrap=”virtual” tabindex=”1″ style=”height: 215px;” class=”formwidth” cols=”45″ rows=”13″ onkeydown=”textCounter(this.form.COMMENTS,this.form.remLen1,9000);” onkeyup=”textCounter(this.form.COMMENTS,this.form.remLen1,9000);”></textarea><br />
<input disabled=”disabled” type=”text” name=”remLen1″ size=”4″ maxlength=”4″ value=”9000″ /> characters left | <a href=”#” onclick=”return alter_box_height(‘COMMENTS’, 100)”>Increase size</a> | <a href=”#” onclick=”return alter_box_height(‘COMMENTS’, -100)”>Decrease size</a></td>
</tr>
[/code]

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@mrhooJul 23.2006 — The height of a text area depends on the rows attribute and the style (padding and font ) of the text area. You can specify or alter these values with script.
Copy linkTweet thisAlerts:
@DanUKauthorJul 23.2006 — Yes, I know you can change it with a script - hence why above I have a script, it's just not working.

Thanks.
Copy linkTweet thisAlerts:
@DanUKauthorJul 23.2006 — Any ideas? still can't get this working - thanks. ?
Copy linkTweet thisAlerts:
@DanUKauthorJul 27.2006 — bump
×

Success!

Help @DanUK spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...