Solved

How to assign response from AJAX's call to appropriate checkbox?

Posted on 2012-03-16
2
263 Views
Last Modified: 2012-06-21
Hi Experts,

How to assign response from AJAX's call to appropriate checkbox?

var query = $.ajax({
	type: "POST",
	cache: false,
	url: "<?php echo site_url('/test/update'); ?>",
	data: { mytext: mytext },
	dataType: 'json',
	success: function(theresponse) {
		$("#response").html(theresponse.message);
		
		// HOW TO FIND CHECKBOX WITH theresponse.id THEN update the row with theresponse.value
		
		
	},
	error: function() {
		$("#response").html("AJAX request failed.");
	}
});

<div id="page">		
	<p id="response"></p>
</div>
<table id="dataTable" width="350px" border="0">
<tr><td><INPUT type='checkbox' value='productid1' name='chk[]' class='chk'/></td><td>ProductID to update 1</td></tr>
<tr><td><INPUT type='checkbox' value='productid2' name='chk[]' class='chk'/></td><td>ProductID to update 2</td></tr>
<tr><td><INPUT type='checkbox' value='productid3' name='chk[]' class='chk'/></td><td>ProductID to update 3</td></tr>
</table>

Open in new window


For example how to update checkbox with id: productid2?

Thanks before.
0
Comment
Question by:jimmycdinata
[X]
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
  • 2
2 Comments
 
LVL 13

Accepted Solution

by:
ansudhindra earned 500 total points
ID: 37728329
check this..

http://jsfiddle.net/Sudhindra/tackc/

is this what you are looking for??
0
 
LVL 13

Expert Comment

by:ansudhindra
ID: 37728335
if not you have to provide id attribute for each dom element and then you can do with

$('#'+resid).parent().next().html(resval);

for example: if response.id is "c2" then you should have in your HTML or DOM
<input type="cehckbox" name="chk[]" id="c2" value="productidn" class="chk" />
0

Featured Post

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

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

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
This article discusses how to implement server side field validation and display customized error messages to the client.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

726 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