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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:17:00+00:00 2026-05-30T23:17:00+00:00

I am trying to have the users avatar change based on what account they

  • 0

I am trying to have the users avatar change based on what account they have selected from a dropdown box. I wrote some jQuery that I think should work as I am using it for a similar application to do the same thing ( with facebook urls not twitter )

http://jsfiddle.net/JPT3K/3/

<select id="twid-4646464" onChange="updateTwPic(4646464);">
  <option value="billpull-1">BillPull</option>
  <option value="billpull1-2">BillPull1</option>
</select>

 function updateTwPic(postid){
    var twhandle = $('#twid-'+postid).val().split('-');
    twhandle = twhandle[0];
    var picurl = "http://api.twitter.com/1/users/profile_image/"+twhandle;
    $('#twpic-'+postid).attr('src',picurl);
 }​
  • 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-30T23:17:01+00:00Added an answer on May 30, 2026 at 11:17 pm

    Your code works fine if set up correctly: http://jsfiddle.net/86nfP/

    Note that I changed onDomReady to no wrap (head).

    So what went wrong? updateTwPic was defined not in the global scope but in the ready event handler, so JavaScript could not find it.
    If you have had a look at the console, you would have seen:

    Uncaught ReferenceError: updateTwPic is not defined


    You could simply attach the event handler with jQuery to avoid such problems:

    $(function() {
        // this code runs when the DOM is loaded, no matter where it is located
        $('#twid-4646464').change(function() {
            var postid = this.id.split('-')[1],
                picurl = "http://api.twitter.com/1/users/profile_image/"+this.value.split('-')[1];
            $('#twpic-'+postid).attr('src',picurl);
        });
    });
    

    You could also make use of data-* attributes, which would be even cleaner:

    <select id="twid-4646464" data-postid="4646464">
    

    and in the event handler:

    var postid = $.data(this, 'postid');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to join two tables (USERS AND USERS_ROLES) based on their
I'm trying to generate a report of the activities that users have done within
I'm trying to create an iOS (iPhone specific) app where users have to authenticate
I have been trying to integrate Facebook with my app to allow users to
I'm trying to get a count of users who have paid for a service
I'm trying to get a list of users who have authorized my Twitter application.
I have a table with users and are trying to get a list with
im trying to send rest api Users.getLoggedInUser i have all the secret session and
I am trying to get the zip code of the users current location.I have
I'm trying to create a simple widget to retrieve a users feeds, I have

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.