Hi, I have a textarea, and with CSS I've assigned a background and a color.
Now is there a way to assign to this textarea a rows and cols value ?
I need the CSS value to have priority over the regular textarea values.
Thanks,
Sharg
| SitePoint Sponsor |
Hi, I have a textarea, and with CSS I've assigned a background and a color.
Now is there a way to assign to this textarea a rows and cols value ?
I need the CSS value to have priority over the regular textarea values.
Thanks,
Sharg


With CSS, I really doubt it. However, it can be done in JavaScript using something like this (replacing the "myNames" with the names of your form and textarea)...
document.myForm.myArea.rows = "40"
document.myForm.myArea.cols = "30"
Let me know if you need more details on the JavaScript solution.![]()





scrubz...
Would your answer would work if there are values already assigned in the textarea tag? I would bet it would not work. I am guessing he wants this solution to some sort of code that he HAS to embed.
Adobe Certified Coldfusion MX 7 Developer
Adobe Certified Advanced Coldfusion MX Developer
My Blog (new) | My Family | My Freelance | My Recipes


Good news: It does work if there are already values for rows and cols in the textarea tag. Bad news: It doesn't work at all in Netscape 4.x (although there may be a solution if I spent some time with it).
An example:
<html>
<head>
<title>Untitled</title>
<script language="JavaScript">
<!--
function changeTextarea() {
var theArea = document.myForm.myArea
if (theArea.rows == "30" && theArea.cols == "50")
{theArea.rows = "15"
theArea.cols = "10"}
else
{theArea.rows = "30"
theArea.cols = "50"}
}
// -->
</script>
</head>
<body>
<form name="myForm" method="post" action="">
<input type="button" value="Resize Textarea" onClick="changeTextarea();"><br>
<textarea name="myArea" rows="15" cols="10"></textarea><br>
</form>
</body>
</html>
Thanks for your answer.
The main reason I asked was because Netscape 4.x was causing me some troubles already !.
Sad that people are still using it.
maybe we can't do anything about netscape, as long as some users still use them. Take care also with the number of cols, as netscape and explorer behave diffent with each one. A textarea of 60 cols is not the same width in netscape and in explorer.





why doesn't Netscape just ask people to stop using their own browser?
if they would just lay down and die, then things would be MUCH easier...
Adobe Certified Coldfusion MX 7 Developer
Adobe Certified Advanced Coldfusion MX Developer
My Blog (new) | My Family | My Freelance | My Recipes





Hmm..I don't understand...why can't you just specify it using the normal html method?
You could try the width element of CSS1 though.
I haven't tried it, but it works for netscpae, mozilla and ie browsers when used on <input> fields.
"Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world."
-- Albert Einstein
Bookmarks