History: Profile_CDF_instructions_page
Source of version: 7
Copy to clipboard
Show case of how to use the plugin jquery to conditionally hide or display some fields in a form To be continued.... In the mean time, see this: * https://dev.tiki.org/item5642 * http://xavi-9794-5642.show.tikiwiki.org To be refactored still with the appropriate reference (instead of fixed numbers) for fields {TRACKER(trackerId="1" fields="$profileobject:cdf_id$:$profileobject:cdf_campText$:$profileobject:cdf_header$:$profileobject:cdf_usuari$:$profileobject:cdf_campRadioButton$:$profileobject:cdf_staticText$:$profileobject:cdf_multiSelectCheckboxes$:$profileobject:cdf_multiSelectList$:$profileobject:cdf_computedField$:$profileobject:cdf_campNumeric$:$profileobject:cdf_campDesplegableAmbAltres$:$profileobject:cdf_data$:$profileobject:cdf_campAreaDeText$:$profileobject:cdf_campDatepicker$:$profileobject:cdf_sort_default_field$:$profileobject:cdf_campDesplegable$" showtitle="y" showdesc="y" showfieldsdesc="y" showmandatory="y" showstatus="y")}Item inserted! __((Homepage|Add a new one))__{TRACKER} {JQ()} $("input[name=ins_$profileobject:cdf_campRadioButton$]").change(function(){ if ($(this).val() === '0') { $("input[name=ins_$profileobject:cdf_campNumeric$]").parents("tr:first").hide("slow"); $("input[name=ins_$profileobject:cdf_campNumeric$]").val(""); $("select[name=ins_$profileobject:cdf_campDesplegableAmbAltres$]").parents("tr:first").hide("slow"); $("select[name=ins_$profileobject:cdf_campDesplegableAmbAltres$]").val("").trigger("chosen:updated") $("input[name=other_ins_$profileobject:cdf_campDesplegableAmbAltres$]").val(""); $("select[name=ins_$profileobject:cdf_data$Year]").parents("tr:first").hide("slow"); $("select", ".tracker_field$profileobject:cdf_data$").val("").trigger("chosen:updated"); $("textarea[name=ins_$profileobject:cdf_campAreaDeText$]").parents("tr:first").hide("slow"); $("textarea[name=ins_$profileobject:cdf_campAreaDeText$]").val(""); $("input[name=ins_$profileobject:cdf_campDatepicker$]").parents("tr:first").hide("slow"); $("input[name=ins_$profileobject:cdf_campDatepicker$]").next().val(""); $("input[name=ins_$profileobject:cdf_campRadioButton$]").parents("tr:first") .css('font-weight', 'bold') .css('background-color', 'lightgreen') .focus(function() { $(this) .css('font-weight', '') .css('background-color', ''); }); $(".wikiplugin_tracker:eq(1) tr").slice(7, 11).css({backgroundColor:"lightgreen", fontStyle:"italic", color:"grey"}); $("label[for=ins_$profileobject:cdf_staticText$]").parents("tr:first").show("slow"); $("input[name=ins_$profileobject:cdf_multiSelectCheckboxes$_old]").parents("tr:first").show("slow"); $("label[for=ins_$profileobject:cdf_multiSelectList$]").parents("tr:first").show("slow"); $("label[for=ins_$profileobject:cdf_computedField$]").parents("tr:first").show("slow"); } else if ($(this).val() === '1') { $("input[name=ins_$profileobject:cdf_campNumeric$]").parents("tr:first").show("slow"); $("select[name=ins_$profileobject:cdf_campDesplegableAmbAltres$]").parents("tr:first").show("slow"); $("select[name=ins_$profileobject:cdf_data$Year]").parents("tr:first").show("slow"); $("textarea[name=ins_$profileobject:cdf_campAreaDeText$]").parents("tr:first").show("slow"); $("input[name=ins_$profileobject:cdf_campDatepicker$]").parents("tr:first").show("slow"); $(".wikiplugin_tracker:eq(1) tr").slice(2, 7).css({backgroundColor:"lightyellow", fontStyle:"italic", color:"grey"}); $("input[name=ins_$profileobject:cdf_campRadioButton$]").parents("tr:first") .css('font-weight', 'bold') .css('background-color', 'lightyellow') .focus(function() { $(this) .css('font-weight', '') .css('background-color', ''); }); $("label[for=ins_$profileobject:cdf_staticText$]").parents("tr:first").hide("slow"); $("input[name=ins_$profileobject:cdf_multiSelectCheckboxes$_old]").parents("tr:first").hide("slow"); $("input[name='ins_$profileobject:cdf_multiSelectCheckboxes$[]']").prop("checked", false) $("label[for=ins_$profileobject:cdf_multiSelectList$]").parents("tr:first").hide("slow"); $("select[name='ins_$profileobject:cdf_multiSelectList$[]'] option:selected").prop("selected", false) $("select[name='ins_$profileobject:cdf_multiSelectList$[]']").trigger("chosen:updated") $("label[for=ins_$profileobject:cdf_computedField$]").parents("tr:first").hide("slow"); } else { $("input[name=ins_$profileobject:cdf_campNumeric$]").parents("tr:first").hide("slow"); $("input[name=ins_$profileobject:cdf_campNumeric$]").val(""); $("select[name=ins_$profileobject:cdf_campDesplegableAmbAltres$]").parents("tr:first").hide("slow"); $("select[name=ins_$profileobject:cdf_campDesplegableAmbAltres$]").val("").trigger("chosen:updated"); $("input[name=other_ins_$profileobject:cdf_campDesplegableAmbAltres$]").val("").trigger("chosen:updated"); $("select[name=ins_$profileobject:cdf_data$Year]").parents("tr:first").hide("slow"); $("select", ".tracker_field$profileobject:cdf_data$").val("").trigger("chosen:updated") $("textarea[name=ins_$profileobject:cdf_campAreaDeText$]").parents("tr:first").hide("slow"); $("textarea[name=ins_$profileobject:cdf_campAreaDeText$]").val(""); $("label[for=ins_$profileobject:cdf_campDatepicker$]").parents("tr:first").hide("slow"); $("#" + $("input[name=ins_$profileobject:cdf_campDatepicker$]").attr("id") + "_dptxt").val(""); $("label[for=ins_$profileobject:cdf_staticText$]").parents("tr:first").hide("slow"); $("input[name=ins_$profileobject:cdf_staticText$]").val(""); $("input[name=ins_$profileobject:cdf_multiSelectCheckboxes$_old]").parents("tr:first").hide("slow"); $("input[name='ins_$profileobject:cdf_multiSelectCheckboxes$[]']").prop("checked", false) $("label[for=ins_$profileobject:cdf_multiSelectList$]").parents("tr:first").hide("slow"); $("select[name='ins_$profileobject:cdf_multiSelectList$[]'] option:selected").prop("selected", false) $("select[name='ins_$profileobject:cdf_multiSelectList$[]']").trigger("chosen:updated") $("label[for=ins_$profileobject:cdf_computedField$]").parents("tr:first").hide("slow"); $("label[for=ins_$profileobject:cdf_computedField$]").val(""); $("input[name=ins_$profileobject:cdf_campRadioButton$]").parents("tr:first") .css('font-weight', 'normal') .css('background-color', 'lightgrey') .focus(function() { $(this) .css('font-weight', '') .css('background-color', ''); }); } }); $("input[name=ins_$profileobject:cdf_campNumeric$]").parents("tr:first").hide(); $("select[name=ins_$profileobject:cdf_campDesplegableAmbAltres$]").parents("tr:first").hide(); $("select[name=ins_$profileobject:cdf_data$Year]").parents("tr:first").hide(); $("textarea[name=ins_$profileobject:cdf_campAreaDeText$]").parents("tr:first").hide(); $("input[name=ins_$profileobject:cdf_campDatepicker$]").parents("tr:first").hide(); $("label[for=ins_$profileobject:cdf_staticText$]").parents("tr:first").hide(); $("input[name=ins_$profileobject:cdf_multiSelectCheckboxes$_old]").parents("tr:first").hide(); $("label[for=ins_$profileobject:cdf_multiSelectList$]").parents("tr:first").hide(); $("label[for=ins_$profileobject:cdf_computedField$]").parents("tr:first").hide(); {JQ} {CODE()} [FIELD1] fieldId = 1 name = #Id permName = id position = 0 type = q options = {"start":1,"prepend":"#","append":"","itemId":""} isMain = n isTblVisible = y isSearchable = y isPublic = y isHidden = n isMandatory = y description = descriptionIsParsed = n [FIELD4] fieldId = 4 name = Title of item (as a Text field) permName = campText position = 10 type = t options = {"samerow":1,"size":80,"prepend":"","append":"","max":100,"autocomplete":"y","exact":"n"} isMain = y isTblVisible = y isSearchable = y isPublic = y isHidden = n isMandatory = y description = descriptionIsParsed = n [FIELD11] fieldId = 11 name = Header permName = header position = 20 type = h options = {"level":1,"toggle":"o"} isMain = n isTblVisible = n isSearchable = y isPublic = y isHidden = n isMandatory = n description = descriptionIsParsed = n [FIELD2] fieldId = 2 name = User field permName = usuari position = 30 type = u options = {"autoassign":1,"notify":0,"groupIds":[0],"showRealname":0} isMain = n isTblVisible = n isSearchable = y isPublic = y isHidden = n isMandatory = n description = descriptionIsParsed = n [FIELD9] fieldId = 9 name = Which is your case? permName = campRadioButton position = 40 type = R options = {"options":["0=Case A","1=Case B","3=Unknown"]} isMain = n isTblVisible = y isSearchable = y isPublic = y isHidden = n isMandatory = n description = descriptionIsParsed = n [FIELD3] fieldId = 3 name = Case B Numeric field permName = campNumeric position = 50 type = n options = {"samerow":1,"size":20,"prepend":"","append":"","decimals":0,"dec_point":".","thousands":","} isMain = n isTblVisible = n isSearchable = y isPublic = y isHidden = n isMandatory = n description = descriptionIsParsed = n [FIELD6] fieldId = 6 name = Case B Dropdown with other field permName = campDesplegableAmbAltres position = 60 type = D options = {"options":["0","1","2","3"]} isMain = n isTblVisible = n isSearchable = y isPublic = y isHidden = n isMandatory = n description = descriptionIsParsed = n [FIELD7] fieldId = 7 name = Case B date time field permName = data position = 70 type = f options = {"datetime":"dt","startyear":"2001","endyear":"2016","blankdate":"blank"} isMain = n isTblVisible = n isSearchable = y isPublic = y isHidden = n isMandatory = n description = descriptionIsParsed = n [FIELD8] fieldId = 8 name = Case B Text area field permName = campAreaDeText position = 80 type = a options = {"toolbars":1,"width":80,"height":5,"max":10000,"listmax":200,"wordmax":0,"distinct":"n","wysiwyg":"n","samerow":1} isMain = n isTblVisible = n isSearchable = y isPublic = y isHidden = n isMandatory = n description = Pots afegir més informació i comentaris aquí descriptionIsParsed = y [FIELD10] fieldId = 10 name = Case B datepicker field permName = campDatepicker position = 90 type = j options = {"datetime":"dt","useNow":0} isMain = n isTblVisible = n isSearchable = y isPublic = y isHidden = n isMandatory = n description = descriptionIsParsed = n [FIELD12] fieldId = 12 name = Case A. Static Text permName = staticText position = 100 type = S options = {"wikiparse":1,"max":100} isMain = n isTblVisible = n isSearchable = y isPublic = y isHidden = n isMandatory = n description = My ~~red:description~~ as ''__static text__'' comes here descriptionIsParsed = y [FIELD13] fieldId = 13 name = Case A. Multiple Selection Checkboxes permName = multiSelectCheckboxes position = 110 type = M options = {"options":["0=foo","1=bar","2=oh yeah"],"inputtype":""} isMain = n isTblVisible = n isSearchable = y isPublic = y isHidden = n isMandatory = n description = descriptionIsParsed = n [FIELD14] fieldId = 14 name = Case A. Multiple Selection List permName = multiSelectList position = 120 type = M options = {"options":["0=foo","1=bar","2=oh yeah"],"inputtype":"m"} isMain = n isTblVisible = n isSearchable = y isPublic = y isHidden = n isMandatory = n description = descriptionIsParsed = n [FIELD15] fieldId = 15 name = Case A. Computed field permName = computedField position = 130 type = C options = {"formula":"#10-#7"} isMain = n isTblVisible = n isSearchable = y isPublic = y isHidden = n isMandatory = n description = Computed based on a formula. For dates, it shows: y=years, m=months, w=weeks, d=days, h=hours descriptionIsParsed = n [FIELD5] fieldId = 5 name = Common Drop down field permName = campDesplegable position = 140 type = d options = {"options":["1","2","2","3"]} isMain = n isTblVisible = n isSearchable = y isPublic = y isHidden = n isMandatory = n description = for all cases (A, B or unknown) descriptionIsParsed = n {CODE}