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 196423
In Process

The Archive Base Latest Questions

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

Background I have two select form fields chained together: duration and frequency. When the

  • 0

Background
I have two select form fields chained together: duration and frequency. When the user selects a frequency, the duration options are dynamically inserted. There are default options, but those are just so that the field isn’t empty when the user expands it.

For example, the frequency options are “day”, “other day”, and “week”. If I select “day”, the frequency options change to “5 days”, “15 days”, and “30 days”.

Problem
The problem comes when the user submits the form with errors, the form is returned with all the form fields re-populated and the errors highlighted — except for the Frequency select field — whose options are dynamically generated. It is not highlighted and it’s options are the default options.

Is there a way that I can have these options re-populated if the user submits with an error. We are doing quite a bit of JavaScript validation, so this situation shouldn’t happen that often, but would like to make getting an error as painless an experience as possible for the users.

Code
I’m using jquery and a jquery plugin called cascade to chain the two fields together.
(http://plugins.jquery.com/project/cascade)

Here’s my custom JavaScript.

This script generates the list of options:

var list1 = [
    {'When':'86400','Value':' ','Text':' '},
    {'When':'172800','Value':' ','Text':' '},
    {'When':'604800','Value':' ','Text':' '},
    {'When':'86400','Value':'432000','Text':'5 days'},
    {'When':'86400','Value':'1296000','Text':'15 days'},
    {'When':'86400','Value':'2505600','Text':'30 days'},
    {'When':'172800','Value':'1296000','Text':'15 days'},
    {'When':'172800','Value':'2505600','Text':'30 days'},
    {'When':'172800','Value':'3888000','Text':'45 days'},
    {'When':'604800','Value':'2505600','Text':'4 weeks'},
    {'When':'604800','Value':'3715200','Text':'6 weeks'},
    {'When':'604800','Value':'4924800','Text':'8 weeks'}
];

function commonTemplate(item) {
    return "<option value='" + item.Value + "'>" + item.Text + "</option>"; 
};

function commonMatch(selectedValue) {
    return this.When == selectedValue; 
};

And this is the script that triggers the generation of the select options:

jQuery("#duration).cascade("#frequency",{
    list: list1,            
    template: commonTemplate,
    match: commonMatch          
})

The Question
Any thoughts on how to get the dynamically generated frequency options to re-populate when the form is returned to the browser with errors? Could either use the cascade plugin I’m currently using or some other method?

Help is muchly appreciated. 🙂

  • 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-11T16:45:58+00:00Added an answer on May 11, 2026 at 4:45 pm

    I am not familiar with this plugin, but couldn’t you just fire the change() event of #duration and/or #frequency on document.ready?

    $(document).ready(function() {
        $('#duration').change();
        $('#frequency').change();
    });
    

    I am pretty sure all the script is doing is binding stuff to the change event of the select (by default, at least) so that should trigger the plugin to work its magic…

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

Sidebar

Related Questions

Is it possible to have two background images? For instance, I'd like to have
Background This question is in two parts. I have a one-way WCF operation hosted
Background: I have a little video playing app with a UI inspired by the
Background I have a massive db for a SharePoint site collection. It is 130GB
Background I have been asked by a client to create a picture of the
Background: I have a kubuntu laptop right now that I can't use wirelessly, i.e.
Background: we have an application that generates reports from HTML (that may or may
Background: I have a module which declares a number of instance methods module UsefulThings
Background I have made a Web Service in Visual Studio, and I'm trying to
Background I have an application written in native C++ over the course of several

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.