User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 375,170 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,210 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 1070 | Replies: 5
Reply
Join Date: Apr 2007
Posts: 17
Reputation: obscured47 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
obscured47 obscured47 is offline Offline
Newbie Poster

xhtml-javascript taxtarea problem

  #1  
Apr 29th, 2007
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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2006
Location: Deptford, London
Posts: 916
Reputation: MattEvans will become famous soon enough MattEvans will become famous soon enough 
Rep Power: 5
Solved Threads: 46
Moderator
Featured Poster
MattEvans's Avatar
MattEvans MattEvans is offline Offline
Posting Shark

Re: xhtml-javascript taxtarea problem

  #2  
Apr 29th, 2007
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:
  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:

table.center
{
margin-left:auto;
margin-right:auto;
}

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..
If it only works in Internet Explorer; it doesn't work.
Reply With Quote  
Join Date: Apr 2007
Posts: 17
Reputation: obscured47 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
obscured47 obscured47 is offline Offline
Newbie Poster

Re: xhtml-javascript taxtarea problem

  #3  
Apr 29th, 2007
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 8:26 pm.
Reply With Quote  
Join Date: Jul 2006
Location: Deptford, London
Posts: 916
Reputation: MattEvans will become famous soon enough MattEvans will become famous soon enough 
Rep Power: 5
Solved Threads: 46
Moderator
Featured Poster
MattEvans's Avatar
MattEvans MattEvans is offline Offline
Posting Shark

Re: xhtml-javascript taxtarea problem

  #4  
Apr 29th, 2007
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.

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...
If it only works in Internet Explorer; it doesn't work.
Reply With Quote  
Join Date: Apr 2007
Posts: 17
Reputation: obscured47 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
obscured47 obscured47 is offline Offline
Newbie Poster

Re: xhtml-javascript taxtarea problem

  #5  
May 1st, 2007
great, thanks MattEvans
Reply With Quote  
Join Date: Jan 2007
Posts: 2,433
Reputation: MidiMagic is on a distinguished road 
Rep Power: 6
Solved Threads: 99
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Nearly a Posting Maven

Re: xhtml-javascript taxtarea problem

  #6  
May 3rd, 2007
Textarea size is directly defined in terms of character rows and columns.
Daylight-saving time uses more gasoline
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb JavaScript / DHTML / AJAX Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 11:49 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC