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 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

Ask A Question

Stats

  • Questions 188k
  • Answers 188k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I've managed to connect fdb.exe from the command line to… May 12, 2026 at 5:39 pm
  • Editorial Team
    Editorial Team added an answer Use the header function to send the correct status code:… May 12, 2026 at 5:39 pm
  • Editorial Team
    Editorial Team added an answer You need to do: alert($(this).attr('value')); May 12, 2026 at 5:39 pm

Related Questions

IDE: Microsoft Visual Studio Professional 2008 Language: C# Background: I have one form and
I have been learning how to create dynamic images and dynamic stylesheets using ASP.NET
Background I'm receiving the following error when trying to render a partial view in
I have two databases, one is an MS Access file, the other is a

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.