View Single Post
  #4  
Old 09-27-2014, 02:41 PM
IntoRain's Avatar
IntoRain IntoRain is offline
Moderator
 
Join Date: Jul 2013
Location: Portugal
Posts: 461
Gender: Female
Credits: 22,409
IntoRain is on a distinguished road
Default

Example of how to create a form, a dropdown list with options, display them and then retrieve information from the dropdown list:

PHP Code:
            //create a form: Form(form_name, page_to_redirect, method)
            
$formExample = new Form("exampleform""page_to_send_to_here""post");
            
            
//create a dropdown list object: DropdownList(name)
             
$exampleDropdown = new DropdownList("myList");
              
              
//add options to dropdown list: Option(option_name_displayed, option_value)
                 
$exampleDropdown->add(new Option("Option1""option1")); 
                 
$exampleDropdown->add(new Option("Option2""option2")); 
                 
                 
//add dropdown list to form
                 
$formExample->add($exampleDropdown);
                 
//add button to form
                 
$formExample->add(new Button("Click Me""submit""submit"));
                 
//add form to document to display it
                 
$document->add($formExample);   
                 
                 
//after clicking button to submit form
                 
if($mysidia->input->post("submit")){
                       
//retrieve option selected in the dropdown list, by the dropdown list name
                       
$chosenOption $mysidia->input->post("myList");
                       
$document->add(new Comment("I chose this: {$chosenOption}"));
                 } 
__________________


asp.net stole my soul.
Reply With Quote