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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:26:59+00:00 2026-05-28T14:26:59+00:00

I’ve got some code like the following. I want it so that when I

  • 0

I’ve got some code like the following. I want it so that when I chose an item in ‘select 1’ it changes the in the second combo box but I’m not sure of the best way to go about it. Does it have to be AJax or can it be done with just Javascript?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
  <p>
    <label for="select1">Select 1</label>
    <select name="select1" id="select1">
      <option>Item 1</option>
      <option>Item 2</option>
      <option>Item 3</option>
      <option>Item 4</option>
    </select>
  </p>
  <p>
    <label for="Select2">Select 2</label>
    <select name="Select2" id="Select2">
      <option>List 1</option>
      <option>List 2</option>
      <option>List 3</option>
    </select>
  </p>

</form>
</body>
</html>

Any tips would be appreciated. Tom

  • 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-28T14:26:59+00:00Added an answer on May 28, 2026 at 2:26 pm

    Here:

    <html>
        <head>
            <!-- Connect jQuery from Google library storage -->
            <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
        </head>
        <body>
            <!-- Create select for class, with id #class -->
            <select id="class" name="class">
                <option value="0">Econom</option>
                <option value="1">Business</option>
                <option value="2">First</option>
            </select>
            <!-- Create select for place, with id #place -->
            <select id="place" name="place" disabled="disabled"></select>
            <!-- Create view place for price, with id #price -->
            <span id="price"></span>
            <script type="text/javascript">
                // available places to choose 
                var available = {
                    0:      {
                        25: 50
                    },
                    1:      {
                        26: 100
                    },
                    2:      {
                        21: 200,
                    },
                }
    
                // When the document is totally loaded, do that things that's defined in function(e) {}
                $(document).ready(function(e){
                    // Bind trigger for class select changing, where $('select#class') - find element that in DOM select inputs and has id="class"
                    // When it change, call function(e) {}, inside this function $(this) will be the select itself
                    $('select#class').live('change', function(e){
                        // find place select input
                        var place = $('select#place');
                        // if it's disabled, unblock it, and clean all options inside
                        place.removeAttr('disabled').find('option').remove();
                        // foreach places in available create option and put it into place select
                        for (var i in available[$(this).val()]) {
                            place.append($('<option />').val(i).html(i));
                        }
                        // behave like place select have changed, and trigger listener above
                        place.change();
                    });
    
                    $('select#place').live('change', function(e){
                        $('span#price').html(available[$('select#class').val()][$(this).val()]);
                    });
                });
            </script>
        </body>
    </html>
    

    Totally working example.
    Somehow like that.

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

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.