Last active
December 27, 2015 22:59
-
-
Save abdullahbutt/7403147 to your computer and use it in GitHub Desktop.
CI form dropdown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Now let's imagine that you are writing a data entry form in HTML, and you want | |
a drop-down query box. Let's say this drop-down query box shows three options and allows the user to select one of them. In HTML, a drop-down box can be created like this: | |
<select name="type"> | |
<option value="1">www.this.com</option> | |
<option value="2">www.that.com</option> | |
<option value="3" selected>www.theother.com</option> | |
</select> | |
CI's version is both shorter and, because it works from an array, more adapted to PHP processing: | |
$urlarray = array( | |
'1' => 'www.this.com', | |
'2' => 'www.that.com', | |
'3' => 'www.theother.com', | |
); | |
$variable .= form_dropdown('url', $urlarray, '1'); | |
As $variable is not defined, we can echo it as below: | |
echo form_dropdown('url', $urlarray, '1'); | |
In HTML, you need to type 154 characters; in CI, 128. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment