add alt attribute value to textbox

Posted on 2014-07-25
Last Modified: 2014-07-25

I need to add a alt tag attribute added to textbox with the ID Value from JSON  (( Example ID":34))
 <input type="text" name="3" id="hold1" autocomplete="off" Value="9000.0000" alt="34">   to the input text box.
see example
Question by:Seven price
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 21

Expert Comment

by:Randy Poole
ID: 40219460
$('#mybox').attr('alt', 'Your text');

Open in new window

LVL 58

Accepted Solution

Gary earned 250 total points
ID: 40219465

$.each(result.d, function(i, item) {

Open in new window

LVL 21

Assisted Solution

by:Randy Poole
Randy Poole earned 250 total points
ID: 40219511
You have a couple things wrong, first your string creating your json are missing " around ID and ntID in your first dimension. You are also using this instead of item with trying to access your attributes of your json.  Finally you are not parsing your result into json before trying to access it.

result= {d:'[{"ID":34,"ntID":20006,"APT":3,"hold":9000.0000},{"ID":35,"ntID":20006,"APT":9,"hold":3333.0000},{"ID":36,"ntID":20006,"APT":16,"hold":4434.0000},{"ID":38,"ntID":20006,"APT":18,"hold":1234.0000}]'};

$.each($.parseJSON(result.d), function(i, item) {

Open in new window

Major Serverless Shift

Comparison of major players like AWS, Microsoft Azure, IBM Bluemix, and Google Cloud Platform

LVL 58

Expert Comment

ID: 40219557
You don't need to 'parse' it
LVL 21

Expert Comment

by:Randy Poole
ID: 40219643
If you do not parse it,  result.d is just going to be a string not an object or array.  Not sure how you would issue a foreach loop on a string.

Author Closing Comment

by:Seven price
ID: 40219649

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hi all! Recently there was EE question and the person wanted to have a multi-column textbox <div> selection, so as a first step to answer I provided a link but that was not complete with JavaScript selection, but had a good style sheet. So as a ques…
PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question