Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Aug 2010
    Location
    myeik
    Posts
    81
    Thanks
    6
    Thanked 5 Times in 5 Posts

    dropdown-output-in-codeigniter-with-multidimentional-array

    Code:
    [
    	{
    	id: "1",
    	country_code: "SG",
    	type: "Tourist",
    	exempt_countries: "JP",
    	exempt_conditions: "",
    	cost: "65.00",
    	markup: "10.00",
    	requirements: [
    		{
    		id: "1",
    		visa_id: "1",
    		type: "card",
    		title: "National Identity Card",
    		desc: ""
    		},
    		{
    		id: "2",
    		visa_id: "1",
    		type: "card",
    		title: "Business Card",
    		desc: ""
    		},
    		{
    		id: "3",
    		visa_id: "1",
    		type: "letter",
    		title: "Invitation Letter",
    		desc: ""
    		},
    		{
    		id: "4",
    		visa_id: "1",
    		type: "letter",
    		title: "Introduction Letter",
    		desc: ""
    		},
    		{
    		id: "5",
    		visa_id: "1",
    		type: "photo",
    		title: "Photograph",
    		desc: ""
    		},
    		{
    		id: "6",
    		visa_id: "1",
    		type: "form",
    		title: "Application Form",
    		desc: ""
    		}
    		],
    	country: {},
    	price: 75
    	},
    	{},
    	{},
    	{}
    ]
    Controller

    PHP Code:
    $this->load->view('admin/visa/edit.php'compact('id','visa')); 

    View
    Code:
    <table class="table" id='req_table'>  
            <thead>  
              <tr>  
                <th>Name</th>  
                <th>Type</th>  
                <th>Description</th>  
                <th>Remove</th>  
              </tr>  
            </thead>  
    
            <tbody>  
                 <?php foreach($visa['requirements'] as $key => $visaa) {?>
              <tr class="row-template insert_section">                             
                <td class="row-template"> <input type="text" name="requirements[<?= $key ?>][title]" value="<?= $visaa['title']?>"/></td> 
    
                <td>
    
    
                    <?php
                        echo form_dropdown('visa', $visaa, 'type');
                     ?>          
    
                </td>  
    
                <td><textarea class="form-control" name="requirements[<?= $key ?>][desc]"><?= $visaa['desc']?></textarea></td>  
                <td><button class='deleterow'>Delete</button></td>  
    
              </tr>
               <?php }?>
            </tbody> 
    
          </table>
    First I want to display the value of the requirement type value and I want to show all the data (requirements['type']) in the dropdown list(form_dropdown)

    Thanks a lot

  • #2
    Regular Coder
    Join Date
    Sep 2002
    Posts
    456
    Thanks
    0
    Thanked 20 Times in 20 Posts
    Question:
    id: "2",
    visa_id: "1",
    type: "card",
    title: "Business Card",
    desc: ""

    <input type="text" name="requirements[<?= $key ?>][title]" value="<?= $visaa['title']?>"/>
    does this really work?

    if the $key is 'title' then isn't $visaa 'Business Card' the value of the $key? So why $visaa['title'] or <?= $key ?>][title]
    just wondering.

    Since I don't know what each param stands for I'll take a shot:heheh
    if($key == 'type'){
    echo form_dropdown('visa', $key, $visaa);
    }
    NO Limits!! DHCreationStation.com
    ------------------------------------------------------------
    Broken items wanted for tinkerin'! PostItNow@BrokenEquipment.com
    Global Complaint Dept.

  • Users who have thanked c1lonewolf for this post:

    minkoko (02-17-2014)

  • #3
    New Coder
    Join Date
    Aug 2010
    Location
    myeik
    Posts
    81
    Thanks
    6
    Thanked 5 Times in 5 Posts
    Now i use like this bro.
    It ok now
    Thanks a lot
    Code:
     <?php
                        $options = array(
                          'card'  => 'Card',
                          'letter' => 'Letter',
                          'form'   => 'Form',
                          'photo' => 'Photograph',
                        );
    
                        echo form_dropdown("requirements[$key][type]", $options, $visaa['type']);
                     ?>


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •