0

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;
	}



}
?>
3
Contributors
7
Replies
8
Views
7 Years
Discussion Span
Last Post by vaultdweller123
0

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))

Edited by diafol: n/a

0

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.

-1

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]))
0

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

0

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??

Edited by diafol: n/a

0

ok thanx.

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

0

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

document.getElementById("textarea_id").value

Edited by vaultdweller123: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.