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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T21:33:42+00:00 2026-05-20T21:33:42+00:00

I want my form to extend in different ways depending on the selection of

  • 0

I want my form to extend in different ways depending on the selection of a drop down box.

I have got my JavaScript working so that onchanging my selection it will carry out something. But I am trying to use the appendTo() method as I have used before; for adding a single input, to work for implementing a div and a few inputs. Its not working, hence the post 😉

So I was hoping you could enlighten me as to a better method?

Here is my current code (courtesy of Mark):

var selectmenu = document.getElementById("type");
selectmenu.onchange = function() {
var chosenoption = parseInt(this.options[this.selectedIndex].value);
switch (chosenoption) {
case 1:
    $('<input type="text" value="1"/>').appendTo('#temp');
    break;
case 2:
    $('<input type="text" value="2"/>').appendTo('#temp');
    break;
case 3:
    $('<input type="text" value="3"/>').appendTo('#temp');
    break;
}
};

note: updated since answers.

here is constructed in jsfiddle

It does nothing currently.

Please help? 😀

  • 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-20T21:33:42+00:00Added an answer on May 20, 2026 at 9:33 pm

    I think value you are trying to case on is a string not a number

    try this

    $(document).ready(function(){
        $('#type').change(function() {
            if( $(this).val() != "nothing" ){
                switch ($(this).val()) {
                case "1":
                    $('<input type="text" value="item 1" />').appendTo('#temp'); 
                    break;
                case "2":
                    $('<input type="text" value="item 2" />').appendTo('#temp');  
                    break;
                case "3":
                    $('<input type="text" value="item 3" />').appendTo('#temp'); 
                    break;
                }
            }else{
                alert($(this).val());
            }
        });
    })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on sencha2.0. I have one login form and I want to
I want a simple form with one text box and a submit button. For
I want that the form will not close by doing Alt + F4 but
i have a form and want to submit it with a script. i'm going
I'm creating a simple form and in this form I want to have an
I have a custom registration BrowserView where you have to extend some userdata (z3c.form
Let's say you have two classes that extend UserControl . Each of the controls
I have this struct: Example.Form = Ext.extend(Ext.form.FormPanel, { // other element , onSuccess:function(form, action)
I have a lot of form classes all of which extend Form . I
I have a windows forms app written in C++/cli. I want to extend this

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.