Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2012-03-16
2
Medium Priority
?
268 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 2000 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

Industry Leaders: 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

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

610 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