Re: Generating forms using OOP

From: Date: Sat, 07 Dec 2002 05:20:11 +0000
Subject: Re: Generating forms using OOP
References: 1  Groups: php.general php.windows 
Request: Send a blank email to php-general+get-127367@lists.php.net to get a copy of this message
Hi, Saturday, December 7, 2002, 9:43:47 AM, you wrote: DO> Hi People, DO> I ve just started with some OOP programming in PHP and now i have to DO> build a set of classes that can generate a html form.. But i have a DO> problem with the <select><option></option></select> thing.... DO> I hope someone can help me here or give me some pointers,... any help is DO> apreciated. Here is a part of my code : DO> class selectField extends formElement { DO> //Constructor DO> function selectField($name, $value) { DO> formElement::setName($name); DO> formElement::setValue($value); DO> } DO> function generateSelectField() { DO> $theOutput = "<select DO> name=\"".$this->name."\">\n"; DO> foreach($this->value as $key=>$val) { DO> $theOutput .= "<option value=\"".$this->>value."\">".$this->value."</option>\n"; DO> } DO> $theOutput .= "</select>\n"; DO> Return $theOutput; DO> } DO> } DO> This is how i call the Object: DO> $test[] = "Test1"; DO> $test[] = "Test2"; DO> $test[] = "Test3"; DO> $test[] = "Test4"; DO> $test[] = "Test5"; DO> $select = new selectField("testje", $test); echo$select->>generateSelectField(); DO> But all i get is a select box with the word Array in it 5 times...Thanks DO> for your time... DO> Best regards, DO> Davy Obdam DO> mailto:info@davyobdam.com The output function is wrong it should be function generateSelectField() { $theOutput = "<select name=\"".$this->name."\">\n"; foreach($this->value as $key=>$val) { $theOutput .= "<option value=\"".$val."\">".$val."</option>\n"; //this line } $theOutput .= "</select>\n"; Return $theOutput; } -- regards, Tom

« previous php.general (#127367) next »