Newbie needs help to fix text in a textarea

This is a discussion on Newbie needs help to fix text in a textarea within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hi, I'm a newbie needing help to fix imported text in a textarea i.e so that the imported ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-01-2007
raj
 
Posts: n/a
Default Newbie needs help to fix text in a textarea

Hi,

I'm a newbie needing help to fix imported text in a textarea i.e so that the
imported text in the text area cannot be changed in the webbrowser. Here's
the code snippet:

<p><textarea name="textarea2" cols="70" rows="7" wrap="virtual"><?php
include("contracts/termsandconditions.txt"); ?></textarea></p>

Thank you in advance,

Raj

Reply With Quote
  #2 (permalink)  
Old 01-01-2007
OmegaJunior
 
Posts: n/a
Default Re: Newbie needs help to fix text in a textarea

On Mon, 01 Jan 2007 17:43:16 +0100, raj <raj@nospam.com> wrote:

> Hi,
>
> I'm a newbie needing help to fix imported text in a textarea i.e so that
> the
> imported text in the text area cannot be changed in the webbrowser.
> Here's
> the code snippet:
>
> <p><textarea name="textarea2" cols="70" rows="7" wrap="virtual"><?php
> include("contracts/termsandconditions.txt"); ?></textarea></p>
>
> Thank you in advance,
>
> Raj
>

Basically you're looking to disable the textarea element. Check out the
"disabled" attribute in the html4 specification:
http://www.w3.org/TR/html401/interac...#adef-disabled

You'd use it like this:
<textarea disabled="disabled" ...>

But that's only the first step. Although the text can't be edited in the
page, there's nothing preventing a malevolent visitor from editing it
elsewhere and submitting the changed text to the form handler.

Thus in your form handler you also must make sure not to include this
textarea. If you need the text, include it in your form handler (a second
time, since you already included it in the form) but don't read it from
the textarea.

Hope this helps!


--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Reply With Quote
  #3 (permalink)  
Old 01-01-2007
raj
 
Posts: n/a
Default Re: Newbie needs help to fix text in a textarea

On Mon, 1 Jan 2007 16:49:52 +0000, OmegaJunior wrote
(in article <op.tlhidevg70mclq@cp139795-a.landg1.lb.home.nl>):

> On Mon, 01 Jan 2007 17:43:16 +0100, raj <raj@nospam.com> wrote:
>
>> Hi,
>>
>> I'm a newbie needing help to fix imported text in a textarea i.e so that
>> the
>> imported text in the text area cannot be changed in the webbrowser.
>> Here's
>> the code snippet:
>>
>> <p><textarea name="textarea2" cols="70" rows="7" wrap="virtual"><?php
>> include("contracts/termsandconditions.txt"); ?></textarea></p>
>>
>> Thank you in advance,
>>
>> Raj
>>

> Basically you're looking to disable the textarea element. Check out the
> "disabled" attribute in the html4 specification:
> http://www.w3.org/TR/html401/interac...#adef-disabled
>
> You'd use it like this:
> <textarea disabled="disabled" ...>
>
> But that's only the first step. Although the text can't be edited in the
> page, there's nothing preventing a malevolent visitor from editing it
> elsewhere and submitting the changed text to the form handler.
>
> Thus in your form handler you also must make sure not to include this
> textarea. If you need the text, include it in your form handler (a second
> time, since you already included it in the form) but don't read it from
> the textarea.
>
> Hope this helps!
>
>
>


Hi, thanks for the help, especially with the form handler bit.

You've definately helped.

Thank you.

Raj :)

Reply With Quote
  #4 (permalink)  
Old 01-01-2007
raj
 
Posts: n/a
Default Re: Newbie needs help to fix text in a textarea

On Mon, 1 Jan 2007 16:43:16 +0000, raj wrote
(in article <0001HW.C1BEEAA4001125FAB019F94F@news.zen.co.uk> ):

> Hi,
>
> I'm a newbie needing help to fix imported text in a textarea i.e so that the
> imported text in the text area cannot be changed in the webbrowser. Here's
> the code snippet:
>
> <p><textarea name="textarea2" cols="70" rows="7" wrap="virtual"><?php
> include("contracts/termsandconditions.txt"); ?></textarea></p>
>
> Thank you in advance,
>
> Raj
>


a

Reply With Quote
  #5 (permalink)  
Old 01-01-2007
Gleep
 
Posts: n/a
Default Re: Newbie needs help to fix text in a textarea

On Mon, 1 Jan 2007 16:43:16 +0000, raj <raj@nospam.com> wrote:

>Hi,
>
>I'm a newbie needing help to fix imported text in a textarea i.e so that the
>imported text in the text area cannot be changed in the webbrowser. Here's
>the code snippet:
>
><p><textarea name="textarea2" cols="70" rows="7" wrap="virtual"><?php
>include("contracts/termsandconditions.txt"); ?></textarea></p>
>
>Thank you in advance,
>
>Raj





It doesn't make sense to bring this into a textarea. Just bring it into the web page in a div or
span or p

however if you insist on having this in a text area - you could 'disable' the textarea
i found this online somewhere

17.12 Disabled and read-only controls
In contexts where user input is either undesirable or irrelevant, it is important to be able to
disable a control or render it read-only. For example, one may want to disable a form's submit
button until the user has entered some required data. Similarly, an author may want to include a
piece of read-only text that must be submitted as a value along with the form. The following
sections describe disabled and read-only controls.

17.12.1 Disabled controls
Attribute definitions

disabled [CI]
When set for a form control, this boolean attribute disables the control for user input.
When set, the disabled attribute has the following effects on an element:

Disabled controls do not receive focus.
Disabled controls are skipped in tabbing navigation.
Disabled controls cannot be successful.
The following elements support the disabled attribute: BUTTON, INPUT, OPTGROUP, OPTION, SELECT, and
TEXTAREA.

This attribute is inherited but local declarations override the inherited value.

How disabled elements are rendered depends on the user agent. For example, some user agents "gray
out" disabled menu items, button labels, etc.

In this example, the INPUT element is disabled. Therefore, it cannot receive user input nor will its
value be submitted with the form.

<INPUT disabled name="fred" value="stone">


Note. The only way to modify dynamically the value of the disabled attribute is through a script.

17.12.2 Read-only controls
Attribute definitions

readonly [CI]
When set for a form control, this boolean attribute prohibits changes to the control.
The readonly attribute specifies whether the control may be modified by the user.

When set, the readonly attribute has the following effects on an element:

Read-only elements receive focus but cannot be modified by the user.
Read-only elements are included in tabbing navigation.
Read-only elements may be successful.
The following elements support the readonly attribute: INPUT and TEXTAREA.

How read-only elements are rendered depends on the user agent.

Note. The only way to modify dynamically the value of the readonly attribute is through a script.


Reply With Quote
  #6 (permalink)  
Old 01-01-2007
raj
 
Posts: n/a
Default Re: Newbie needs help to fix text in a textarea

On Mon, 1 Jan 2007 16:43:16 +0000, raj wrote
(in article <0001HW.C1BEEAA4001125FAB019F94F@news.zen.co.uk> ):

> Hi,
>
> I'm a newbie needing help to fix imported text in a textarea i.e so that the
> imported text in the text area cannot be changed in the webbrowser. Here's
> the code snippet:
>
> <p><textarea name="textarea2" cols="70" rows="7" wrap="virtual"><?php
> include("contracts/termsandconditions.txt"); ?></textarea></p>
>
> Thank you in advance,
>
> Raj
>


b

Reply With Quote
  #7 (permalink)  
Old 01-01-2007
raj
 
Posts: n/a
Default Re: Newbie needs help to fix text in a textarea

On Mon, 1 Jan 2007 18:50:54 +0000, Gleep wrote
(in article <crlip2hpo7hrsjckt2qqjdp8ukfj2tap0a@4ax.com>):

> On Mon, 1 Jan 2007 16:43:16 +0000, raj <raj@nospam.com> wrote:
>
>> Hi,
>>
>> I'm a newbie needing help to fix imported text in a textarea i.e so that
>> the
>> imported text in the text area cannot be changed in the webbrowser. Here's
>> the code snippet:
>>
>> <p><textarea name="textarea2" cols="70" rows="7" wrap="virtual"><?php
>> include("contracts/termsandconditions.txt"); ?></textarea></p>
>>
>> Thank you in advance,
>>
>> Raj

>
>
>
>
> It doesn't make sense to bring this into a textarea. Just bring it into the
> web page in a div or
> span or p
>
> however if you insist on having this in a text area - you could 'disable'
> the textarea
> i found this online somewhere
>
> 17.12 Disabled and read-only controls
> In contexts where user input is either undesirable or irrelevant, it is
> important to be able to
> disable a control or render it read-only. For example, one may want to
> disable a form's submit
> button until the user has entered some required data. Similarly, an author
> may want to include a
> piece of read-only text that must be submitted as a value along with the
> form. The following
> sections describe disabled and read-only controls.
>
> 17.12.1 Disabled controls
> Attribute definitions
>
> disabled [CI]
> When set for a form control, this boolean attribute disables the control for
> user input.
> When set, the disabled attribute has the following effects on an element:
>
> Disabled controls do not receive focus.
> Disabled controls are skipped in tabbing navigation.
> Disabled controls cannot be successful.
> The following elements support the disabled attribute: BUTTON, INPUT,
> OPTGROUP, OPTION, SELECT, and
> TEXTAREA.
>
> This attribute is inherited but local declarations override the inherited
> value.
>
> How disabled elements are rendered depends on the user agent. For example,
> some user agents "gray
> out" disabled menu items, button labels, etc.
>
> In this example, the INPUT element is disabled. Therefore, it cannot receive
> user input nor will its
> value be submitted with the form.
>
> <INPUT disabled name="fred" value="stone">
>
>
> Note. The only way to modify dynamically the value of the disabled attribute
> is through a script.
>
> 17.12.2 Read-only controls
> Attribute definitions
>
> readonly [CI]
> When set for a form control, this boolean attribute prohibits changes to the
> control.
> The readonly attribute specifies whether the control may be modified by the
> user.
>
> When set, the readonly attribute has the following effects on an element:
>
> Read-only elements receive focus but cannot be modified by the user.
> Read-only elements are included in tabbing navigation.
> Read-only elements may be successful.
> The following elements support the readonly attribute: INPUT and TEXTAREA.
>
> How read-only elements are rendered depends on the user agent.
>
> Note. The only way to modify dynamically the value of the readonly attribute
> is through a script.
>
>


Thanks Gleep. Much appreciated.

Raj

Reply With Quote
  #8 (permalink)  
Old 01-02-2007
Krustov
 
Posts: n/a
Default Re: Newbie needs help to fix text in a textarea

<comp.lang.php>
<raj>
<Mon, 1 Jan 2007 16:43:16 +0000>
<0001HW.C1BEEAA4001125FAB019F94F@news.zen.co.uk>

> I'm a newbie needing help to fix imported text in a textarea i.e so that the
> imported text in the text area cannot be changed in the webbrowser. Here's
> the code snippet:
>
> <p><textarea name="textarea2" cols="70" rows="7" wrap="virtual"><?php
> include("contracts/termsandconditions.txt"); ?></textarea></p>
>


<textarea name="textarea2" disabled cols="70" rows="7">

Will grey the text .

<textarea name="textarea2" readonly cols="70" rows="7">

Will display the text as normal .


--
www.phptakeaway.co.uk
(work in progress)
Reply With Quote
  #9 (permalink)  
Old 01-02-2007
william.clarke
 
Posts: n/a
Default Re: Newbie needs help to fix text in a textarea


Krustov wrote:
> <comp.lang.php>
> <raj>
> <Mon, 1 Jan 2007 16:43:16 +0000>
> <0001HW.C1BEEAA4001125FAB019F94F@news.zen.co.uk>
>
> > I'm a newbie needing help to fix imported text in a textarea i.e so that the
> > imported text in the text area cannot be changed in the webbrowser. Here's
> > the code snippet:
> >
> > <p><textarea name="textarea2" cols="70" rows="7" wrap="virtual"><?php
> > include("contracts/termsandconditions.txt"); ?></textarea></p>
> >

>
> <textarea name="textarea2" disabled cols="70" rows="7">
>
> Will grey the text .
>
> <textarea name="textarea2" readonly cols="70" rows="7">
>
> Will display the text as normal .
>
>
> --
> www.phptakeaway.co.uk
> (work in progress)


Why put it in a text area if it isn't edittable? You could just display
the text in an iframe on a page if you want the scroll bar look,
otherwise surely a bordered div would give the same effect, without
having to worry about users editing things? You probably have a good
reason for doing things this way, but I generally only display form
controls if a user can actually interact with them.

Reply With Quote
  #10 (permalink)  
Old 01-02-2007
Krustov
 
Posts: n/a
Default Re: Newbie needs help to fix text in a textarea

<comp.lang.php>
<william.clarke>
<2 Jan 2007 14:16:55 -0800>
<1167776215.468085.66010@a3g2000cwd.googlegroups.c om>

> > > I'm a newbie needing help to fix imported text in a textarea i.e so that the
> > > imported text in the text area cannot be changed in the webbrowser. Here's
> > > the code snippet:
> > >
> > > <p><textarea name="textarea2" cols="70" rows="7" wrap="virtual"><?php
> > > include("contracts/termsandconditions.txt"); ?></textarea></p>
> > >

> >
> > <textarea name="textarea2" disabled cols="70" rows="7">
> >
> > Will grey the text .
> >
> > <textarea name="textarea2" readonly cols="70" rows="7">
> >
> > Will display the text as normal .
> >

>
> Why put it in a text area if it isn't edittable?
>


I was tempted to ask the same thing - but life is too short for that
sort of thing and its usually best just to supply the answer :-)


--
www.phptakeaway.co.uk
(work in progress)
Reply With Quote
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

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



All times are GMT +1. The time now is 11:13 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0