Forum Discussion
JoshuaTate
8 years agoQrew Cadet
There is a code solution if you search the forum - IOL javascript by Dan
JoshuaTate
8 years agoQrew Cadet
Hi Christian,
Below handles text and checkbox's - Numbers and dates will also record so long as a text box or checkbox is edited after - yet to work out how to resolve this. I have also added a script to capture and insert the IP address of the logged in user. please see below code:
Below handles text and checkbox's - Numbers and dates will also record so long as a text box or checkbox is edited after - yet to work out how to resolve this. I have also added a script to capture and insert the IP address of the logged in user. please see below code:
// Below sets up the IPPromise to be called later
var IPpromise = $.ajax({
type: "GET",
url: "https://api.ipify.org/?format=jsonp";,
dataType: "jsonp"
});
$.ajaxSetup({data: {apptoken: apptoken}});
$("#_fid_6, #_fid_9, #_fid_64, #_fid_98, #_fid_150, #_fid_72, #_fid_114, #_fid_132, #_fid_77, #_fid_85, #_fid_7, #_fid_8, #_fid_11, #_fid_12, #_fid_13, #_fid_14, #_fid_15, #_fid_16, #_fid_17, #_fid_18, #_fid_19, #_fid_20, #_fid_21, #_fid_22, #_fid_23, #_fid_24, #_fid_25, #_fid_26, #_fid_27, #_fid_28, #_fid_29, #_fid_30, #_fid_31, #_fid_32, #_fid_33, #_fid_34, #_fid_35, #_fid_36, #_fid_37, #_fid_38, #_fid_39, #_fid_40, #_fid_41, #_fid_42, #_fid_43, #_fid_44, #_fid_45, #_fid_46, #_fid_47, #_fid_48, #_fid_49, #_fid_50, #_fid_51, #_fid_52, #_fid_53, #_fid_54, #_fid_55, #_fid_56, #_fid_57, #_fid_58, #_fid_59, #_fid_60, #_fid_61, #_fid_62, #_fid_63, #_fid_65, #_fid_66, #_fid_67, #_fid_68, #_fid_69, #_fid_70, #_fid_71, #_fid_91, #_fid_100, #_fid_102, #_fid_122, #_fid_127, #_fid_129, #_fid_133, #_fid_136, #_fid_139, #_fid_140, #_fid_147, #_fid_149, #_fid_153 , #_fid_154 , #_fid_155 , #_fid_156 , #_fid_157 , #_fid_158 , #_fid_159 , #_fid_160 , #_fid_161 , #_fid_162").on("change", function() {
log = [];
_.each([6, 9, 64, 98, 150, 72, 114, 132, 77, 85, 7, 8, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 65, 66, 67, 68, 69, 70, 71, 91, 100, 102, 122, 127, 129, 133, 136, 139, 140, 147, 149, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162], function(fid) {
oldValue = $("[name=_fid_oval_" + fid + "]").val();
newValue = $("#_fid_" + fid).val();
newcheckValue = $("#_fid_" + fid).prop("checked");
oldcheckValue = $("[name=_fid_oval_" + fid + "]").prop("checked");
type = $("#_fid_" + fid).attr("type");
if (oldValue != newValue) {
label = $("label[for=_fid_" + fid + "]").text();
if (type == "checkbox" && oldcheckValue != newcheckValue) { // Push to log if checkbox AND values unequal
log.push(label + " was =" + (oldcheckValue ? "true" : "false") + "; now =" + newcheckValue);
}
else if (type == "checkbox" && oldcheckValue == newcheckValue) { // Do nothing if checkbox AND values equal
} else { // Push to log if not a checkbox or date
log.push(label + " was =" + oldValue + "; now =" + newValue);
}
}
})
// Below pushs the IP address from the promise above
$.when(IPpromise).then(function(json) {
var ip = json.ip;
log.push("IP of User: " + ip);
});
$("#_fid_152").html(log.join("\n"));
});