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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:35:03+00:00 2026-06-04T02:35:03+00:00

I have several inputs, some are provided with default value, some are empty, and

  • 0

I have several inputs, some are provided with default value, some are empty, and filled up by a select value dynamically.

When I do a select, the value of select box is inserted into the input text.

The problem is when textfield is empty, and then later filled up with the select value, and then using a reset/clear button, the input text is not emptied, yet it is still holding the dynamic inserted value:

Inputs:

<input type="text" value="" name="yahoo">
<input type="text" value="some default value" name="google">
<button class="button clear" type="button" accesskey="x">Clear</button>

Jquery:

$('button.clear').click(function () {
  $('input').val(''); // this clears google, but not yahoo
});

And some select box input the values dynamically to textfields.
Any idea to completely empty the textfield?
Thanks

Steps:

  1. I do change a select box

  2. The value of select is inserted into textfield. All is well

  3. The problem is when default is empty, the clear button do not empty the textfield (which is dynamically filled up)

I will clarify my question with simplified code:

$('select').swicthClass();

$.fn.swicthClass = function (options) {
 // .............
};

var src = 'some-value-from-select-box'; // hence good, bad etc
$('body.bad').find('input[name="yahoo"]').val(src); 



<select>
  <option selected="selected" value="good">Good</option>
      <option value="bad">Bad</option>
      <option value="worse">Worse</option>
      <option value="damn">Damn</option>
    </select>
  • 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-06-04T02:35:05+00:00Added an answer on June 4, 2026 at 2:35 am

    You might want to try this

    $('button.clear').click(function () {
      $('input').val('');
    });
    
    $("select").on("change", function() {
      var src = 'good';
      $('[name=yahoo]').val(src); 
    });
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
    <input type="text" value="" name="yahoo" >
    <input type="text" value="some default value" name="google">
    <button class="button clear" type="button" accesskey="x">Clear</button>
    
    <select>
      <option selected="selected" value="good">Good</option>
      <option value="bad">Bad</option>
      <option value="worse">Worse</option>
      <option value="damn">Damn</option>
    </select>
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have... a dynamic populated select box several input boxes a submit button form
I have a search form with inputs and selects, and when any input/select is
I have a form with id=new I have several text inputs and a select
I have an IceFaces form with several HtmlCommandButtons on it. I have some input
I have several textboxes that are generated dynamically based on some results I get
I have a Sweave file, JMP.Rnw that inputs several other files in the same
I have several datepickers tied to input fields. They are created in the usual
I have several textboxes where users can enter information into them. This can include
I have several applications within my domain that accept similar inputs in text fields.
I have a several input fields in a form each having a unique name.

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.