Below is my textarea class. I want to make it sticky..help please.

I have the same problem with my drop down boxes (that post is still unanswered)

class Textarea extends TextBox
{
        
        private $rows;
        private $cols;
        private $sub_head;

        function __construct($n,$d=NULL)
	{
		$this->name=$n;
                $this->default=$d;
	}

        function setHeight($h)
        {
            $this->rows=$h;
        }

        function setWidth($w)
        {
            $this->cols=$w;
        }

             function setSubHead($sh)
	{
		$this->sub_head=$sh;
	}


           function tooString()
	{
		$text="<tr><tr><td colspan='3'><b>".$this->sub_head."</b></td></tr>
				
				<td colspan='4'><textarea name='".$this->name."' rows='".$this->rows."' cols='".$this->cols."'";



		//The problem lies in the code below...I suppose
		if(isset($_POST[$this->name])&($this->isSticky))
			$text.="value='".$_POST[$this->name]."'";

                else
			$text.="value='".$this->default."'";

                $text.="'/></textarea></td>
                                <td>".$this->description."</td>
				</tr><tr><td></td></tr>";
		return $text;
	}



}
?>
Member Avatar for diafol

waddaya mean? Sticky as in stuck in the same position on the screen?

If so use CSS 'position: fixed', otherwise explain further.

I don't get the table thing. Can't you use CSS?

I'm not going to try and dissect your code, but:

if(isset($_POST[$this->name])&($this->isSticky))

looks like it should be:

if(isset($_POST[$this->name])&&($this->isSticky))

With sticky I meant that when the form reloads because there was an error (eg. user left out some fields), the text that he inserted into the text-area should be inserted into the text-area automatically so that he does not have to type the whole thing over again.

hahaha lol you mean repopulate
btw i dont understand this line of code

if(isset($_POST[$this->name])&($this->isSticky))

where did you get the $this->isSticky ????
can u remove it? instead

if(isset($_POST[$this->name]))

The isSticky is a function I wrote in my textbox class and set to TRUe.

Still not working though...

PS: "Sticky" is how I learnt it! hahahahaha

Member Avatar for diafol

I think it may be due to the fact that textareas don't use the 'value' attribute - they have content not 'values'. Input tags like textboxes use the 'value' attribute to store data:

<input type="text" value="hello" ... />
<textarea ...>hello</textarea>

hahahahaha??

ok thanx.

I will write a class for textarea that does not extend from textbox

data from textarea can be get by value even if it doesn't have a value attribute

document.getElementById("textarea_id").value
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.