Forum Discussion
76 Replies
Sort By
- _anomDiebolt_Qrew EliteYes - I typically just post the essential code that would go in module.js. You may have to make additional modifications depending on your specific needs. Note that this fragment of code does not contain the generic wrapper that decodes what page you are on and places all the code within a closure so that your JavaScript variables will not conflict with QuickBase's globals (they sure have a lot of globals!). See
https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=293 - TaraTaraQrew MemberThanks! I'm not very knowledgeable in javascript so I apologize for my repeated questions. I still can't seem to get it to work. Below is the code that I have on my module.js page. If you could provide any guidance on where I'm going wrong I would greatly appreciate it!!!
(function(){
var querystring=document.location.search;
if (/dlta=mog/i.test(querystring)) {
$("#_fid_341").attr("readonly", "readonly");
var label, oldValue, newValue, log;
$("#_fid_339, #_fid_328, #_fid_203, #_fid_103, #_fid_318", #_fid_27, #_fid_170, #_fid_28).on("change", function() {
log = [];
_.each([339, 328, 203, 103, 318, 27,170, 28], function(fid) {
oldValue = $("[name=_fid_oval_" + fid + "]").val();
newValue = $("#_fid_" + fid).val();
if (oldValue != newValue) {
label = $("label[for=_fid_" + fid + "]").text();
log.push(label + " was =" + oldValue + "; now =" + newValue);
}
});
$("#_fid_341").html(log.join("\n"));
})(); - _anomDiebolt_Qrew EliteYou are testing if you are on the grid edit page:
if (/dlta=mog/i.test(querystring)) {
when I think you intend to test if you are on an edit record page:
if(/a=er/i.test(querystring)) {
Note this logic is used in parallel with the form definition that sets whether or not the [-] field is included on the form in the first place. You may or may not need to include the if statement if you otherwise prevent the [-] field from being on the form/report. - GaryMcRobertsQrew CadetHi Dan,
I have implemented this code and it works great as far as tracking the edits but it's not showing the field label. All i get in the log is was =10:00 am; now =11am without the label before the word "was". Do you know what may be causing this? The code I am using is below, thanks!:
$("#_fid_122").attr("readonly", "readonly");
var label, oldValue, newValue, log;
$("#_fid_8, #_fid_9").on("change", function() {
log = [];
_.each([8, 9], function(fid) {
oldValue = $("[name=_fid_oval_" + fid + "]").val();
newValue = $("#_fid_" + fid).val();
if (oldValue != newValue) {
label = $("label[for=_fid_" + fid + "]").text();
log.push(label + " was =" + oldValue + "; now =" + newValue);
}
});
$("#_fid_122").html(log.join("\n"));
}); - _anomDiebolt_Qrew EliteView source and search for the strings "_fid_8" or "_fid_9" which should be in the page. Post the HTML fragment that you find which includes the <input> and associated <label> tags. If the label is coming back empty but evertyhing else works there is probably just a slight modification to the selector needed on this statement:
label = $("label[for=_fid_" + fid + "]").text();
Please note that this solution would not be possible without the generous support of the Image Onload Foundation. - GaryMcRobertsQrew CadetTHanks, this is what I find for "_fid_8":
<td id="tdl_19" class="label lc" >
<label class="fieldLabel " for='_fid_8'><b ></b></label>
<div id="tdf_19" class="cell cc nowrap" ><input name=_fid_oval_8 type=hidden value='10:00 am'>
<input type=text size=16 name='_fid_8' id='_fid_8' onBlur='OnBF(this)' onFocus='OnFF(this)' value='10:00 am' > - _anomDiebolt_Qrew EliteFor some reason the HTML <label> generated by QuickBase for the label has no text. Since you only have two fids in your loop you could either remove the loop and inline all the statements or keep the loop and insert logic that will supply a hardcoded label value:
//label = $("label[for=_fid_" + fid + "]").text();
if (fid == 8) {
label = "foo";
} else if (label == 9) {
label ="bar";
} else {
label = "missing!";
} - TaraTaraQrew MemberI want this to work so bad, but it's still not working for me. Here is a break down of what I"m doing. If anyone can help, I would REALLY appreciate it.
1.) I created a new text page called module.js with the code below
(function(){
var querystring=document.location.search;
if(/a=er/i.test(querystring)) {
$("#_fid_341").attr("readonly", "readonly");
var label, oldValue, newValue, log;
$("#_fid_339, #_fid_328, #_fid_203, #_fid_103, #_fid_318", #_fid_27, #_fid_170, #_fid_28).on("change", function() {
log = [];
_.each([339, 328, 203, 103, 318, 27,170, 28], function(fid) {
oldValue = $("[name=_fid_oval_" + fid + "]").val();
newValue = $("#_fid_" + fid).val();
if (oldValue != newValue) {
label = $("label[for=_fid_" + fid + "]").text();
log.push(label + " was =" + oldValue + "; now =" + newValue);
}
});
$("#_fid_341").html(log.join("\n"));
});
2.) I created two variables...
The first variable is named "iol" and contains the following:
<img qbu='module' src='/i/clear2x2.gif' onload="javascript:if(typeof QBU=='undefined'){QBU={};$.getScript(gReqAppDBID+'?a=dbpage&pagename=
The second variable is named "/iol" and contains the following:
&rand='+new Date().getTime())};">
3.) In my projects table, I have created a multi line text field called [Change Log]. The field id for this field is 341. Input type is "User Input". I have the box checked for "Allow some HTML tags to be inserted in the field". I have checked "Log the edits to this field, and show them on forms".
4.) In my projects table I have created a formula text field called [-]. The field id for this field is 377. I have checked the box to allow some HTML. The formula for this field is below:
[iol] & "module.js" & [/iol] - TaraTaraQrew MemberI also should add that both the [Change Log] and [-] fields are on my form for the projects table. For the [-] field I have checked the box to use an alternate text label and inserted just a single space in the area where you are supposed to type the alternate text label.
- _anomDiebolt_Qrew EliteYou are missing a set of parenthesis on the very last line of your code:
})();