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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:30:43+00:00 2026-05-25T00:30:43+00:00

We have two dropdowns that according to your selection it changes part of the

  • 0

We have two dropdowns that according to your selection it changes part of the string in some div containers. The purpose of this is to return URLs to give to clients.

This is a sample of the code

<select name="lstLanguage" id="lstLanguage">
    <OPTION VALUE="">-- Generic default ---</OPTION>
    <OPTION ID="Arabic" VALUE="AR">Arabic</OPTION>
    <OPTION ID="German" VALUE="D">German</OPTION>
</select>

<select name="lstTemplate" id="lstTemplate">
    <OPTION VALUE="">-- Generic default ---</OPTION>
    <OPTION VALUE="1">Member</OPTION>
    <OPTION VALUE="2">NonMember</OPTION>
</select>

<div id='Ind_URL'>http://example.com/Registration.asp?Language_Code=?Role=</div>
<div id='Ind_W_URL'>http://example.com/Registration.asp?Language_Code=?Role=</div>
<div id='Login_URL'>http://example.com/?Language_Code=</div>

And this is the jQuery we currently have, which was provided by irama.

$(function(){
    divIDs = [
        'Ind_URL',
        'Ind_W_URL',
        'Login_URL',

    ];

    $('#lstTemplate').bind('change', function(){

        role = $(this).find('option:selected').val();
        updateURLDivs(langCode=null, role);

    });

    $('#lstLanguage').bind('change', function(){

        langCode = $(this).find('option:selected').val();
        updateURLDivs(langCode, role=null);

    });

    updateURLDivs = function (langCode, role) {
        for (i in divIDs) {
            currentDiv = $('#'+divIDs[i]);

            if (langCode !== null) {
                currentDiv.data('Language_Code', langCode);
            }
            if (role !== null) {
                currentDiv.data('role', role);
            }

            // Cache original div contents, so that the select menu can be changed more than once.
                if (typeof currentDiv.data('contents') == 'undefined') {
                    divContents = currentDiv .html();
                    currentDiv .data('contents', divContents);
                } else {
                    divContents = currentDiv .data('contents');
                }

            currentDiv.empty().append(
                divContents
                    .replace('role=','role='+currentDiv.data('role'))
                    .replace('Language_Code=','Language_Code='+currentDiv.data('Language_Code'))

            );
        }
    }
});

This is working fine, but this morning we found a few issues

  • It is currently updating both parameters, no matter if you change one or both. We need it to update if you change the template, just the template and if you change the language just the language.
  • If nothing is selected we need it to replace it with a blank not with undefined as it is currently doing
  • If we change the Template it also needs to replace Registration.asp to PersonImport.asp from the URLs

This is how it should work

  • The div containers need to have the default URLs in them
  • If I change the language (lstLanguage) it should just change the Language_Code on the DIV containers. Then if I select the language option with no value (“Generic default”) the Language_Code should be blank ”
  • If I change the template (lstTemplate) it should change the Role on the DIV containers. Also should change Registration.asp to PersonImport.asp. Then if I select the template option with no value (“Generic Default) the Role should be blank ” and PersonImport.asp should go back to Registration.asp.

I’m not a good coder on this, but it would be great if any of you can give me a hand with this.

Thanks in advance
Federico

  • 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-25T00:30:44+00:00Added an answer on May 25, 2026 at 12:30 am

    I have create a fiddle with a lot of improvement in your code. Take a look.

    Working demo

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

Sidebar

Related Questions

I have a navigation bar that has two dropdowns (as nested ul's). I'm trying
Am I doing this correctly? I have two dropdowns. The first is populated on
I have two dependent dropdowns on a JSF page that work fine. I use
I have two applications written in Java that communicate with each other using XML
I have a webpage with two radiobuttons and a dropdownlist as follows: <div class=sectionheader>Course
I have two dropdowns in my form. The first one Queries for a set
I have two dropdown lists (one dynamically populated, the other not) that determine the
I have two dropdowns. When a user selects a value from the first one
I have two dropdowns in html. Both dropdowns are getting data mysql first dropdown
I have two related dropdowns. When the user selects an option from the first

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.