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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:07:08+00:00 2026-05-22T03:07:08+00:00

There is another solution to display a hidden input when a user choose an

  • 0

There is another solution to display a hidden input when a user choose an option from the select tag?
I want to put the HTML code outside the JS code.

jQuery code:

$(function() {

    var message = new Array(),
        $paymentOption = $("#payement_option"),
        $messageDisplay = $("#message_display");

    message[1] = '<input type="text" name="email" size="30" />';

    $paymentOption.change(function() {

        var messageIndex = $(this).val();

        $messageDisplay.empty();

        if (messageIndex > 0) 
            $messageDisplay.append(message[messageIndex]);

    });

});

HTML code like this:

<select name="option"><option value="0">yes</option><option value="1">no</option</select>

the output:

<div id="message_display"></div>

EDIT:

I want something like:

<div id="message_display">
    <input type="text" name="email" size="30" />
</div>
  • 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-22T03:07:09+00:00Added an answer on May 22, 2026 at 3:07 am

    I, as the others are bit confused, but from my understanding of your problem you have basically working code.

    You need to set select id to payment_option and put the message display div on the page. otherwise it cannot find what it needs to append the value to.

    change it to this:
    HTML

    <select name="option" id="payement_option">
        <option value="0">yes</option>
        <option value="1">no</option>
    </select>
    
    <div id="message_display"></div>
    

    JQUERY

    $(function () {
        var message = new Array();
        //set message[0] = 'stuff' if you want something to display when yes is selected
        message[1] = '<input type="text" name="email" size="30" />';
        $("#payement_option").change(function () {
            //gets the message index
            var message_index = $("#payement_option").val();
            //emptys the value from message display
            $("#message_display").empty();
    
           //if option is not YES display message[val]
            if (message_index > 0) {
                $("#message_display").append(message[message_index]);
            }
        });
    });
    

    and a live example: http://jsfiddle.net/mCqfq/

    EDIT:

    you mean like this? http://jsfiddle.net/dEwcK/

    HTML:

    <select name="option" id="payement_option">
        <option value="0">yes</option>
        <option value="1">no</option>
    </select>
    
    <div id="message_display"><input type="text" name="email" size="30" id="hiddenInput" /></div>
    

    CSS:

    #message_display {display: none;}
    

    JQUERY:

    $(function () {
        $("#payement_option").change(function () {
            var message_index = $("#payement_option").val();
    
    
            if (message_index > 0) {
                $("#message_display").show();
            }
            else { $("#message_display").hide(); }
    
    
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there another way to do this Query ? $query = SELECT * FROM
As the title says, is there another way to pass a variable from "current"
I am currently using an Iframe to display a source from another domain on
I want to display a user's latest Tweets on a webpage while maintaining the
Maybe theres another solution to this. I built a web app that requires 5-10
Is there another way to render graphics in C# beyond GDI+ and XNA ?
Is there another way to get the last child of a div element other
Is there another Timer object that can be used in Silverlight except for the
Is there another way to connect to a MySQL database with what came included
Is there another way to load MSHTML documents without use Application.ProcessMessages? To load a

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.