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

  • Home
  • SEARCH
  • 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 9120149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:33:48+00:00 2026-06-17T05:33:48+00:00

I have to use jquery 1.3.2 I have here very simple task to check

  • 0

I have to use jquery 1.3.2
I have here very simple task to check if button is selected and display a custom text inside certain textfield accordingly. I know that the problem is somewhere in the condition. Inside of condition is simple code to show custom text inside textfield with focus and blur functions

$(document).ready(function () {
  if ($('input#edit-quote-option-flatrate-3---0').is(":checked")) {
    $('input.default').val('xxx');
    $('.default').each(function () {
      var defaultVal = ('xxx');
      $(this).focus(function () {
        if ($(this).val() == defaultVal) {
          $(this).removeClass('active').val('');
        }
      })
        .blur(function () {
        if ($(this).val() == '') {
          $(this).addClass('active').val(defaultVal);
        }
      })
        .blur().addClass('active');
    });
  }
});

Can you please help me debug why does not this code work with the condition? Thank you. Full code with html is here http://jsfiddle.net/NKcFs/

EDIT: On my page, there are more rediobuttons. I need to show text only if this certain button is selected. If visitor selects another button, the text should dissapear.

  • 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-17T05:33:49+00:00Added an answer on June 17, 2026 at 5:33 am

    The problem is that the code only runs when the page loads. If the radio button is selected that that point, then the code actually shows the text in the textbox. To make the code react to changes in the checkbox you should use the change event:

    $(document).ready(function () {
      $('input#edit-quote-option-flatrate-3---0').change(function(){
        if ($('input#edit-quote-option-flatrate-3---0').is(":checked")) {
          $('input.default').val('xxx');
          $('.default').each(function () {
            var defaultVal = ('xxx');
            $(this).focus(function () {
              if ($(this).val() == defaultVal) {
                $(this).removeClass('active').val('');
              }
            })
              .blur(function () {
              if ($(this).val() == '') {
                $(this).addClass('active').val(defaultVal);
              }
            })
            .blur().addClass('active');
          });
        }
      });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a very simple use of datepicker in rails 3.1.3 app with jquery.
I am probably missing something very simple, but here is the situation: I have
I have created a very simple jQuery content slider. I want to turn this
I have a very simple Javascript (jQuery) code, which just add a class name
i have very simple code that i making partial postback by jquery and i
For one of my first ventures into JQuery, I have the very simple goal
I have a very simple gsp page that has a button. I'm trying to
I have started a new web application and have decided to use jquery as
I use jquery flot for my pie charts and I have a problem with
I have to use mootools and jquery files together. But there is a conflict

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.