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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:22:45+00:00 2026-06-01T03:22:45+00:00

Ref: Loading gravatar using jquery I am using the above method to generate the

  • 0

Ref: Loading gravatar using jquery

I am using the above method to generate the gravatar on a page however I have multiple emails on the page and the code is only generating one MD5 and therefore only one gravatar my JS is:

var email = $('#email').val();
var digestString = Crypto.MD5(email);
$('#md5').val(digestString);
var gravatar = $('<img>').attr({src: 'http://www.gravatar.com/avatar/' + digestString});
$('.gravatar').append(gravatar);  

I am using Crypto MD5 http://code.google.com/p/crypto-js/ and that is loaded in the header the emails are held in a hidden input:

<input type="hidden" id="email" value="<?php echo $message['contact_email'];?>">

These are printing out ok for each user.

Any help would be great

EDIT *****

HTML OUTPUT Working:

<div class="message-author">
<span class="gravatar" style="height: 24px;">
      <img src="http://www.gravatar.com/avatar/82c9a9c254f35a912d8fefc248c30fd8"></span>
      <input type="hidden" id="md5" value="82c9a9c254f35a912d8fefc248c30fd8">
      <input type="hidden" class="email" value="themailname@thecompany.com">
</div>

HTML OUTPUT not Working:

<div class="message-author">
<span class="gravatar" style="height: 24px;">
      <img src="http://www.gravatar.com/avatar/82c9a9c254f35a912d8fefc248c30fd8"></span>
      <input type="hidden" id="md5" value="">
      <input type="hidden" class="email" value="themailname@thecompany.com">
</div>

PHP

<?php foreach ($messages['page'] as $message): ?>
    <li class="message">
        <div class="message-body"><?php echo $message['message']; ?></div>
        <div class="message-author">
            <span class="gravatar" style="height: 24px;"></span>
            <input type="hidden" class="md5" value="">
            <input type="hidden" class="email" value="<?php echo $message['contact_email'];?>">
            <?php echo $message['contact_person'];?> - 
            <?php echo date("m M - g:i a", $message['created']); ?>
        </div>
    </li>
<?php endforeach; ?>
  • 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-01T03:22:46+00:00Added an answer on June 1, 2026 at 3:22 am

    Try the following:

    $('input.email').each(function () {
        var self = $(this);
        var md5 = Crypto.MD5(this.value);
    
        self.siblings('.md5').val(md5);
        self.siblings('.gravatar').append($('<img />').prop('src', 'http://www.gravatar.com/avatar/' + md5));
    });
    

    You need to introduce a loop (via each()) to consult each email element individually; otherwise, as you realised, only the first is looked at (as getters such as val() will only return the value of the first matched element.

    However, as I hinted at in my comment, this should really be a job for PHP; it’s also a potentially privacy issue sending users emails in your HTML.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm reloading a web page that has the following code: <label for=showimage>Show Image</label> <input
I am have an issue with the page reloading. I have written a simple
I'm trying to code a page where you can post a comment without reloading
I am currently using the following code to get an UIImage from an ALAsset
I would like to use the universal code and have ran into difficulties getting
I have some code here private void Run() { MyClass c = new MyClass();
If I keep reloading a page that uses jquery from google hosted site. Does
I have a page that is taking 37 seconds to load. While it is
I have put an UITableView inside a UIViewController and have copied code from UITableViewController
REF: http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/Loader.html With regards to a parent SWF loading a child SWF via the

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.