Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8705805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:27:24+00:00 2026-06-13T03:27:24+00:00

I am using jQuery.chained so that when you select a Country from a drop

  • 0

I am using jQuery.chained so that when you select a Country from a drop down it filters a Province/State dropdown. However it requires that each <option> have a class name with the corresponding country.

This is what I have so far

$options = array(
    //Canada
    "AB" => "Alberta",
    "BC" => "British Columbia",
    "MB" => "Manitoba",
    //etc...

    //United States
    "AL" => "Alabama",
    "AK" => "Alaska",
    "AZ" => "Arizona",
    //etc...
);

echo form_dropdown('province', $options, $province);

This gives me

<option value="AB" selected="selected">Alberta</option>
<option value="BC">British Columbia</option>
<option value="MB">Manitoba</option>

<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>

But what I need is

<option value="AB" class="canada" selected="selected">Alberta</option>
<option value="BC" class="canada">British Columbia</option>
<option value="MB" class="canada">Manitoba</option>

<option value="AL" class="us">Alabama</option>
<option value="AK" class="us">Alaska</option>
<option value="AZ" class="us">Arizona</option>

So how would I go about adding a class to each <option>. I would assume I probably need a custom helper but I have no idea how to go about creating one. I am new to coding. Can anyone help me? Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T03:27:26+00:00Added an answer on June 13, 2026 at 3:27 am

    You can extend the default form_helper, create a custom helper, or add the classes via JavaScript.

    CodeIgniter has been created so you can over-ride the existing code very easily

    To create a custom helper

    • open “codeigniter/helpers/form_helper.php”
    • find the “form_dropdown” function, copy it into a new file and save it as “application/helpers/MY_form_helper.php”
    • Make whatever changes to the original method for the dropdown and save it using the same name for the function form_dropdown

    You would load/use the new helper the exact same way you used the old one.

    $this->load->helper('form');
    

    The other option is add the classes via JavaScript before calling the jQuery plugin depending on your level of code skill you might find this option easier.

    CodeIgniter’s user guide is a very useful source of information

    Hope that helps if you have a hard time writing the actual function post what you already tried and I can probably help you with it, The other option would be grab the helper off another CodeIgniter based application or maybe look for a Spark. I know CI-Bonfire has a very useful Address helper and I’m pretty sure I saw a Spark for it also.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using XAMPP Lite - USB Version and found that the jQuery chained select
I am using Mika Tuupola Chained Selects jQuery plugin to build a chained select/dropdown
I'm trying to implement chained filter dropdown using just javascript - jquery. The solution
Using jQuery 1.6.2 HTML that I'm operating on <select id=langId> <option value=0>Argentina - Spanish</option>
I'm trying to implement chained ajax selects from this jQuery plugin: http://www.appelsiini.net/projects/chained I'm using
I am using a jQuery UI Selectmenu by the Filamentgroup to select questions from
tl;dr = Anyone know how to apply chained classes for IE6 using jQuery or
using jquery's .post i send do my php code an object that with var_dump
Using jQuery Nearest Element , I would like to select elements in a circular
Using jQuery I'm trying to obtain the rotation state of an object but in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.