Afternoon,
I am setting the ID’s for a multiple text boxes in my code for items returned from the database.
For example…
<input type="text" id="abcd1234" value="0.00">
basically the id is set when the items are returned, i need to get the id using jQuery so i can then update the value within the textbox with a new price.
I need to return 1) the id, and 2) the value so i can then process it. Could any one suggest how i could do this please?
UPDATE: This is the update function i am looking to use… please ignore the data being passed over cause i will update this once i am able to get the price from the textbox mentioned above. – removed the data. 🙂
$('.update').live('click', function () {
$('#saving').show();
$.ajax({ type: "POST",
url: "../Web.asmx/UpdateData",
data: **JSON will go here**,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
$('#saving').hide();
$('#infoMsg').show();
$('#infoMsg').addClass('er-green');
$('#infoMsg').html("Product was updated successfully.");
},
error: function (msg) {
$('#saving').hide();
$('#infoMsg').show();
$('#infoMsg').addClass('er-yellow');
$('#infoMsg').html("We are unable to update the product at this time.");
}
});
});
Many thanks…
Alan
Not sure which event you want the ID of the input element. The below script will give you the ID of all Input element of type text once the DOM is loaded
Working sample http://jsfiddle.net/p5zbT/4/
EDIT : as per the comment
To get he textboes belongs to one table, change your selector like this
This will select the
inputelements of typetextinside a table(or any HTML element) withIDvalue asdataTable.Working Sample : http://jsfiddle.net/p5zbT/9/