Datei: /pages/tutorials/selectlist/selectlist-06.php
<?php class Selectlist06 extends Page { public function InitializeComponent() { parent::$PAGE_TITLE = "Tutorial : Select an element on a SelectList load values in a second SelectList"; $form = new Form($this); $this->selectlist1 = new SelectList($form); $this->selectlist1->setNbLines(3); $this->selectlist1->addItem("value 1", "value 1"); $this->selectlist1->addItem("value 2", "value 2"); $this->selectlist1->addItem("value 3", "value 3"); $this->selectlist1->addItem("value 4", "value 4"); $this->selectlist1->addItem("value 5", "value 5"); $this->selectlist1->addItem("value 6", "value 6"); $this->selectlist1->onChange("onChangeSelectList"); $this->selectlist1->setAjaxEvent(); $this->selectlist1->setStripTags(); $this->selectlist2 = new SelectList($form); $this->selectlist2->setNbLines(3); $this->selectlist2->setStripTags(); $form->setContent(new WSPObject($this->selectlist1, $this->selectlist2, "<br/>")); $this->render = $form; } public function onChangeSelectList($sender) { $this->selectlist2->removeItems(); $sel_value = $this->selectlist1->getValue(); $this->selectlist2->addItem($sel_value."1", $sel_value."1"); $this->selectlist2->addItem($sel_value."2", $sel_value."2"); $this->selectlist2->addItem($sel_value."3", $sel_value."3"); } } ?>
Zurück zum Tutorial der Komponente Selectlist
|