function retrieveHasilRawatJalan(row, kd_klp) {
var hasil_rawat_jalan2 = <?php echo
Modules::run("lab/get_row_content_from_lab_code","HL-024") ?>;
}
how to replace "HL-024" with variable kd_klp?
i get an error if i use it this way
function retrieveHasilRawatJalan(row, kd_klp) {
var hasil_rawat_jalan2 = <?php echo
Modules::run("lab/get_row_content_from_lab_code",?>kd_klp<?php) ?>;
}
the error say Parse error: syntax error, unexpected '?>'
if my question isnt clear, please ask Thanks^^
UPDATE
Before add AJAX
/**
*
* @param {type} id
* @returns {undefined}
*/
function retrieveHasilRawatJalan(row) {
var hasil_rawat_jalan2 = <? php echo Modules::run("lab/get_row_content_from_lab_code", "HL-003") ?> ;
//var hasil_rawat_jalan2 = <?php //echo Modules::run("lab/get_row_content_from_lab_code", row) ?>;
var number_of_row = parseInt(Object.size(hasil_rawat_jalan2));
var row_start = parseInt(row);
addNewRow(number_of_row);
var row_end = (number_of_row + row_start);
j = 1;
for (i = row_start; i <= row_end; i++) {
document.getElementById('SUBKLP[' + i + ']').value = hasil_rawat_jalan2[j]['sub_klp'];
document.getElementById('NAMA[' + i + ']').value = hasil_rawat_jalan2[j]['name_of_inspection'];
document.getElementById('KODE[' + i + ']').value = hasil_rawat_jalan2[j]['inspection_id'];
document.getElementById('HASIL[' + i + ']').value = hasil_rawat_jalan2[j]['result'];
//document.getElementById('NILAI_NORMAL[' + i + ']').value = hasil_rawat_jalan2[j]['normal_result'];
document.getElementById('NILAI_NORMAL[' + i + ']').value = 'null';
document.getElementById('SATUAN[' + i + ']').value = hasil_rawat_jalan2[j]['measure_unit'];
document.getElementById('KDKLP[' + i + ']').value = hasil_rawat_jalan2[j]['klp_id'];
j++;
}
console.log("row start: " + row_start + ", row end:" + row_end + ", column length: " + number_of_row);
}
After Add AJAX
/**
* test ajax
* @param {type} row
* @returns {undefined}
*/
function retrieveHasilRawatJalan2() {
var row = "HL-003";
var hasil_rawat_jalan2;
var xhttp;
if (window.XMLHttpRequest) {
xhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
//document.getElementById("demo").innerHTML = xhttp.responseText; //to print on <p id="demo"></p>
hasil_rawat_jalan2 = xhttp.responseText;
}
}
//this isnt work
xhttp.open("POST", "<?php echo site_url("
lab / get_row_content_from_lab_code / ") ?>" + row, true);
//this work
xhttp.open("POST", "<?php echo site_url("
lab / get_row_content_from_lab_code /HL-003") ?>", true);
xhttp.send();
var number_of_row = parseInt(Object.size(JSON.parse(hasil_rawat_jalan2))); //try to change hasil_rawat_jalan2 to json but fail.
var row_start = parseInt(row);
addNewRow(number_of_row);
var row_end = (number_of_row + row_start);
j = 1;
for (i = row_start; i <= row_end; i++) {
document.getElementById('SUBKLP[' + i + ']').value = hasil_rawat_jalan2[j]['sub_klp'];
document.getElementById('NAMA[' + i + ']').value = hasil_rawat_jalan2[j]['name_of_inspection'];
document.getElementById('KODE[' + i + ']').value = hasil_rawat_jalan2[j]['inspection_id'];
document.getElementById('HASIL[' + i + ']').value = hasil_rawat_jalan2[j]['result'];
//document.getElementById('NILAI_NORMAL[' + i + ']').value = hasil_rawat_jalan2[j]['normal_result'];
document.getElementById('NILAI_NORMAL[' + i + ']').value = 'null';
document.getElementById('SATUAN[' + i + ']').value = hasil_rawat_jalan2[j]['measure_unit'];
document.getElementById('KDKLP[' + i + ']').value = hasil_rawat_jalan2[j]['klp_id'];
j++;
}
console.log("row start: " + row_start + ", row end:" + row_end + ", column length: " + number_of_row);
}
problems after update ajax,
- I assign
var row = "HL-003";
but i wasnt able to assign variable row toxhttp.open("POST", "<?php echo site_url(" lab / get_row_content_from_lab_code / ") ?>" + row, true);
unless i write it directly like thisxhttp.open("POST", "<?php echo site_url(" lab / get_row_content_from_lab_code /HL-003") ?>", true);
- I get result from
xhttp.open("POST", "<?php echo site_url(" lab / get_row_content_from_lab_code /HL-003") ?>", true);
but it return string not object eventhough format of the string is the same. so i changehasil_rawat_jalan2 = xhttp.responseText;
and addJSON.parse(hasil_rawat_jalan2); //try to change hasil_rawat_jalan2 to object but fail.