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

  • SEARCH
  • Home
  • 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 7408823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:58:45+00:00 2026-05-29T05:58:45+00:00

I have one select box with options and I am using jQuery Chosen on

  • 0

I have one select box with options and I am using jQuery “Chosen” on a Zend View. This plugin is working fine.

Javascript:
$('#select_type').chosen();

My problem is I need to select one of the options when the page loads depending on what the value of type_id is. I tried this:

document.getElementById('select_type').value = '<?=$this->type_id?>';

This changes its value but the option is not selected in the JQuery chosen.

Any ideas?


EDIT: The option successfully changes by doing what I have mentioned above but it does not update/change the selected element in jQuery “chosen” plugin. My question is about updating the selected value for jQuery Chosen not the HTML SELECT (which I have done successfully). Here is a link to jQuery Chosen plugin

  • 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-05-29T05:58:47+00:00Added an answer on May 29, 2026 at 5:58 am

    Update list with JS

    After you run:

    document.getElementById('select_type').value = '<?=$this->type_id?>';
    

    For Chosen version 1 and above (newer)

    You should call:

    $('#select_type').trigger('chosen:updated');
    

    Taken from the Chosen documentation:

    Updating Chosen Dynamically

    If you need to update the options in your select field and want Chosen to pick up the changes, you’ll need to trigger the “chosen:updated” event on the field. Chosen will re-build itself based on the updated content.

    $("#form_field").trigger("chosen:updated");

    See the change log for the announcement of this API change.

    For Chosen versions below 1 (older)

    You should call:

    $('#select_type').trigger('liszt:updated');
    

    Taken from the Chosen documentation:

    Updating Chosen Dynamically

    If you need to update the options in your select field and want Chosen
    to pick up the changes, you’ll need to trigger the “liszt:updated”
    event on the field. Chosen will re-build itself based on the updated
    content.

    • jQuery Version: $("#form_field").trigger("liszt:updated");
    • Prototype Version: Event.fire($("form_field"), "liszt:updated");

    Set the value before calling Chosen

    Instead of doing this from JS why don’t you just set the selected option in the HTML before calling the Chosen plugin with JavaScript? You are setting the value from a piece of PHP so I don’t see why this couldn’t be done.

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

Sidebar

Related Questions

I am using jQuery; I have a select box the options of which are
I'm using jquery uniform on one of the project I'm working on. Since this
i have one form which have some input box and some select box. i
Right now, I have a SQL Query like this one: SELECT X, Y FROM
I have a select box, which i can populate using two methods. First -
I have created one dropdown box <select name=select id=selectId> <option id= value=calendar_Second_Calendar_1285942672.xml>Second Calendar</option> <option
I'm working on a program that uses HTML/CSS/Javascript/JQuery for its user interface. One of
I know this is a daft question but I have a select box with
I have been going through this tutorial on auto-populating boxes using jQuery and Ajax:
Let's say I have a multiple select box: <select id=sel multiple=multiple> <option value=1>One</option> <option

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.