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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:38:58+00:00 2026-05-11T17:38:58+00:00

As you can see on http://jsbin.com/erivi/ I’m using Jquery to change some image (and

  • 0

As you can see on http://jsbin.com/erivi/ I’m using Jquery to change some image (and image attribute) depending on radio button selected, I’m also removing form text when clicking inside it.

And now what I’m trying to do is to change the text of the form depending on the radio button checked.

For example when clicking on "Choice 3" we should see "Text of input 3".

You can see & edit my code live here: http://jsbin.com/erivi/edit

The part I need to improve is:

  imgFldr = 'http://download.kde.org/khotnewstuff/icons/previews/'; 
$("input[type='radio']").click(function() { 
   var strarr = this.title.split('|'); 
   if(strarr.length < 2) return; 
   $('#'+this.name).attr('src', imgFldr+strarr[0]).attr('alt', strarr[1]).attr('title', starr[2]); 
}); 

And particularly .attr('title', starr[2]); which is supposed to change title depending on the 3rd part of my radio title (exemple: title='m602-1.png|Logo 3|Text of input 3' )

Thanks 🙂

Edit: I forgot to mention that I’m using several forms on my real code, that’s why I’m looking for a way to do this without the particular name of the text input in order to avoid repeating script for other text input.

  • 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-11T17:38:58+00:00Added an answer on May 11, 2026 at 5:38 pm

    EDIT: The id of the input textbox has to be unique. Additionally, you need to set .attr('title',strarr[2]), .val(strarr[2]) and the hint class inside the radio button’s click event. Also some changes need to be made to your inputdynvalue plugin.

    Please see the complete updated working code at http://jsbin.com/akawo

    Updated Plug-in code

    (function($) { 
        $.fn.inputdynvalue = function (options) { 
            var opts = $.extend({}, $.fn.inputdynvalue.defaults, options); 
            return this.each(function(){ 
                var hvalue = opts.htext; 
                switch (opts.htext) { 
                    case 'title' : hvalue = $(this).attr('title'); break; 
                    case 'value' : hvalue = $(this).attr('value'); break; 
                } 
                $(this).attr('value', hvalue).addClass(opts.hclass) 
                .unbind('focus blur') 
                .bind('focus', function() {                       
                    if (this.value === this.title) { 
                        this.value = ''; 
                        $(this).removeClass(opts.hclass); 
                    } 
                }) 
                .bind('blur', function() { 
                    if (this.value === '') { 
                        this.value = this.title; 
                        $(this).addClass(opts.hclass); 
                    } 
                }); 
            }); 
        }; 
        $.fn.inputdynvalue.defaults = { 
            htext: 'title', 
            hclass: 'hint' 
        }; 
    })(jQuery); 
    $(document).ready(function(){ 
        $("input[type='text']").inputdynvalue(); 
    });
    

    Updated Radio Button Click Event Handler

    $("input[type='radio']").click(function() { 
       var strarr = this.title.split('|'); 
       if(strarr.length < 2) return; 
       $('#'+this.name).attr('src', imgFldr+strarr[0]).attr('alt', strarr[1]); 
       $('#'+this.name+'_text')
          .attr('title',strarr[2])
          .val(strarr[2])
          .addClass('hint'); 
    }); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

As you can see on this link, http://jsbin.com/ozapol/9 , Jquery disables the scrollbars on
Please check this JSBIN link. http://jsbin.com/axeway/14/edit When you scroll the page you can see
HI all. You can see the code right here: http://jsbin.com/egixa5/5/edit . I'm trying to
I'm using JQuery Scrollables to display an image gallery, see http://www.mba-europe.de/lehr_veroff.html In my setup,
i have put my site in dropbox so you can see it http://dl.dropbox.com/u/13722201/Dorset%20Designs/home.html when
there is an facebook application, you can see it there: http://www.facebook.com/tdmtravelclub?v=app_197602066931325&app_data=wlbb%3D1 You have to
You can see my project here - http://www.inluxphoto.com/custom/jsgallery/index.php I am attempting to make the
using this http://bl.ocks.org/950642 we can see how to add images to nodes, the question
You can view my site here - http://patiss-themes.com/planetary/ and as you can see on
http://zergxost.com/test.html As you can see, if there's not enough text, the bottom gray line

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.