|
 |
|
อยากถามเรื่องคำสั่ง each ของ jquery คือผมมี element ต้องการ loop เทียบกับ string array อะครับ |
|
 |
|
|
 |
 |
|
งง กับคำถามครับ แนะนำให้อ่านเอกสารก่อนถามนะครับ
ผมก็เคยศึกษาเหมือนกัน เรื่องฟังชั่นมันมีเอกสาร ให้ครับ หาโหลดได้
|
 |
 |
 |
 |
Date :
2010-11-02 00:37:05 |
By :
pjgunner.com |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
  
ไม่มีคนช่วย ผมเลยช่วยตัวเองไปจนเสร็จและ เหนื่อยมาก
เอามาโชว์เลย
Code (JavaScript)
function GetQuestionnaireData() {
var questionnaireId = getQueryString("questionnaireId")[0];
$.ajax({
type: "POST",
dataType: "json",
url: "IPadQuestionnaireService.asmx/GetQuestionnaireData",
data: '{"questionnaireId": "' + questionnaireId + '"}',
contentType: "application/json; charset=utf-8",
success: function (message) {
if (message == 'not-rows') {
ShowFailed();
}
else {
//ShowSuccessed();
var value = message.split('|');
var item;
var itemId;
var strElement;
var subElement;
var inputElement;
var OTHERVALUE = "_OTHERVALUE";
$("input").each(function (index) {
var chktTypeElement = $('input')[index].type
if (value.length > 0) {
for (var i = 0; i < value.length; i++) {
item = value[i].split('_');
itemId = item[0] + "_" + item[1] + "_" + item[2];
if (itemId.length == 0)
continue;
else {
strElement = $('input')[index].id;
subElement = strElement.split("_");
inputElement = subElement[0] + "_" + subElement[1] + "_" + subElement[2];
if (chktTypeElement != "text") {
if (inputElement == itemId) {
$('input[id=' + strElement + ']').attr('checked', true);
if (subElement[3] != "OTHER")
continue;
$('input[id=' + strElement + "_VALUE" + ']')[0].value = item[3];
}
}
}
}
}
});
}
},
error: function (xhr, msg) {
ShowFailed();
}
});
}
|
 |
 |
 |
 |
Date :
2010-11-03 10:46:56 |
By :
nooknoname |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|