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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:52:00+00:00 2026-06-06T05:52:00+00:00

Am creating a script using JQuery on an ASP.NET page. Have a JSON string

  • 0

Am creating a script using JQuery on an ASP.NET page. Have a JSON string that looks like this:

<input id="hfImages" type="hidden" value="[
{"ProductID": "000001",
 "Small": "http://myimages.com/images/I/75.jpg",
 "Medium": "http://myimages.com/images/I/160.jpg",
 "Large": "http://myimages.com/images/I/320.jpg",
 "Thumb": "http://myimages.com/images/I/30.jpg"},

{"ProductID": "000002",
 "Small": "http://myimages.com/images/I/75ab.jpg",
 "Medium": "http://myimages.com/images/I/160j.jpg",
 "Large": "http://myimages.com/images/I/320y.jpg",
 "Thumb": "http://myimages.com/images/I/30ii.jpg"},

{"ProductID": "000003",
 "Small": "http://myimages.com/images/I/75.jpg",
 "Medium": "http://myimages.com/images/I/160.jpg",
 "Large": "http://myimages.com/images/I/320.jpg",
 "Thumb": "http://myimages.com/images/I/30.jpg"}
]"/>

I create an object from this string:

var images = $.parseJSON($("#[id*='hfImages']").val());

Have a var called ProductID that contains the value of the “ProductID” I need to get from this JSON string, but I don’t know how to do it. Eventually (once I’ve retrieved the right data from this string), I’d want to be able to do something like this:

$("#productImages img.small").src(image[0].Small)
$("#productImages img.medium").src(image[0].Medium)
$("#productImages img.large").src(image[0].Large)
$("#productImages img.thumb").src(image[0].Thumb)

I’ve seen examples that loop through the JSON object until it finds the desired ‘key’, but I’m thinking there is a simpler way of doing this with .filter or .map?

Am very new to Javascript/JQuery and JSON. Seems like I have a key called “ProductID”, but everything I’m reading doesn’t refer to a single key. As though, every Name in the Name/Value is considered a key.

My problem finding a good example of how to do this probably has to do with my not knowing the right terminologies for everything involved here.

Can someone show me an example in JQuery of how to get an object from the above JSON, given that the desired ProductID is stored as a string in var ProductId? (var ProductID = “000002”;)

I would also appreciate any links to good references on JSON and JQuery. I’ve been to json.org and several others, but they’re not very helpful at my level of knowledge. :S

  • 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-06T05:52:02+00:00Added an answer on June 6, 2026 at 5:52 am

    If you want to find the corresponding element with the given product id you could use the .grep() function.

    Like this:

    var productID = '000002';
    var images = $.parseJSON($("#[id*='hfImages']").val());
    var filteredImages = $.grep(images, function() {
        return this.ProductID == productID;
    });
    
    if (filteredImages.length > 0) {
        // at least one element inside the images array matched the filter criteria
        var product = filteredImages[0];
    
        // you could use product.Small, product.Medium, ... here
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using jQuery1.4.2, ASP.NET MVC 2 and jQuery.UI-1.8. I am creating a data
I'm using this script http://mondaybynoon.com/2009/02/23/creating-custom-form-elements-using-jquery-selects/ to create custom css select boxes in my page.
I have a sliding div on my page which is using jQuery, I'd like
How have you guys handled working with jQuery includes <script type=text/javascript src=jquery.js></script> in Asp.Net
I have created HTML TABLE from JSON data of PHP using JQuery. After creating
I'm creating a new application using ASP.NET MVC. I'd like to use a series
I'm creating an asp.net page that uses the google map api. The page loads
I am creating an XML string using JQuery. I would like to open a
This is for a server status page using php and jquery. The page can
I have a jsFiddle here : http://jsfiddle.net/ZXDYS/22/ I am creating Blogger post summaries using

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.