943,969 Members | Top Members by Rank

Ad:
Apr 29th, 2007
0

xhtml-javascript taxtarea problem

Expand Post »
Hey, sorry if this is a really stupid question but i'm a bit in a hurry, got this coursework due tomorrow and i realised there are some problems with my code.

I have a text area where the user can type a message and change the font-family, font-style, font-size etc dynamically. The problem is that when the user changes one of those things, the textarea resizes. I tried calling a function every time I change those things to fix the size but it's not working in firefox. Any ideas?

And two more small things.
The validator from w3.org gives me error on the <hr /> thing. I have it in the <body> and inside a <p> </p>.
It also gives me error on a <div align="center"> tag and I found out that it's depreciated. How can I make a table have a centered alignment without that?

Sorry if this is too messy

Thanks
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
obscured47 is offline Offline
28 posts
since Apr 2007
Apr 29th, 2007
0

Re: xhtml-javascript taxtarea problem

you cannot put a <hr/> inside a <p>... you shouldn't put anything that constitutes a block ( this includes hr, a div, or another p ) inside a p

For example:
HTML Syntax (Toggle Plain Text)
  1. <p>This is a paragraph!</p>
  2. <hr/>
  3. <p>And this is another</p>
It's usually quite easy to terminate <p>s correctly..

To horizontally center any block level element (like a table) you can use CSS like this:

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. table.center
  2. {
  3. margin-left:auto;
  4. margin-right:auto;
  5. }

With your textarea; in some browsers, they adjust their height to a multiple of the row height ( which is affected by the font-size/family ).
I would say, you might be better off using a different element to display content. If you don't want the textarea font to change but you're changing a page-wide (body) font; you might want to exclude the textarea, by means of giving it a certain font/size in CSS. Otherwise; you may have difficulty getting around this in a 'non-hacky' way. You can set the 'line-height' in CSS; but if it's small, it crops the top/bottom of big text..
Moderator
Featured Poster
Reputation Points: 522
Solved Threads: 64
Veteran Poster
MattEvans is offline Offline
1,091 posts
since Jul 2006
Apr 29th, 2007
0

Re: xhtml-javascript taxtarea problem

Hey thanks for the reply,

I still get an error when i have the <hr /> out of a <p>. It says that it shouldn't be there...

I'm afraid I can't change the textarea now, everything depends on that...may I ask the "haky" way? thanks again
Last edited by obscured47; Apr 29th, 2007 at 9:26 pm.
Reputation Points: 10
Solved Threads: 0
Light Poster
obscured47 is offline Offline
28 posts
since Apr 2007
Apr 29th, 2007
0

Re: xhtml-javascript taxtarea problem

Quote ...
I still get an error when i have the <hr /> out of a <p>. It says that it shouldn't be there...
Hm.. maybe it needs to be in a container; but not the body, that is, you should enclose {everything} inside a big div in order to be able to use <hr/> at top level. It's a wierd rule that, only in XHTML strict I think.

Quote ...
I'm afraid I can't change the textarea now, everything depends on that...may I ask the "haky" way? thanks again
Well. One way is to set the textarea's borders to nothing ( I think, in CSS "border-style:none;" should do that ) and put it inside a container div with the same background color, which is a little bit higher than the textarea itself; then apply a border to that div. That way, it'll appear like the textarea never changes size, even though it does a little. It should only be a little bit bigger; because the size difference is just a compensation for the textarea not being at a multiple of the row height high; BUT that'll only work if you set a specific height for the textarea, and make sure that you DON'T specify the textarea's 'rows' in its attributes (because will probably override the prefered height).

If you're not using borders on the textarea anyway, and it's just pushing the content underneath down a bit, still put it inside a div with a slightly oversize height... It's a bit like, putting gaps between wooden planks so they can expand when it rains without splitting...
Moderator
Featured Poster
Reputation Points: 522
Solved Threads: 64
Veteran Poster
MattEvans is offline Offline
1,091 posts
since Jul 2006
May 1st, 2007
0

Re: xhtml-javascript taxtarea problem

great, thanks MattEvans
Reputation Points: 10
Solved Threads: 0
Light Poster
obscured47 is offline Offline
28 posts
since Apr 2007
May 3rd, 2007
0

Re: xhtml-javascript taxtarea problem

Textarea size is directly defined in terms of character rows and columns.
Reputation Points: 730
Solved Threads: 181
Nearly a Senior Poster
MidiMagic is offline Offline
3,314 posts
since Jan 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: Strange Javascript results
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: Can I have a form without having an associated file.





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC