HelpSpot Help Desk Software | HelpSpot Blog | HelpSpot Support

jQuery Append function - Custom Fields


#1

Hi,

Request Form page (Portal):
I would like to append an HTML next to Custom Field input.
Such as:

Where should I place my append function in the templates? If there are another way to work it out, please share it.
I tried in the header as well as the request.tpl file, but it doesn’t work.

Apprecaite it


#2

In request.tpl.php should work. Could you share the code you are using?


#4

At the top of the template: PORTAL(imc.helpspot.com)
< script >
function isValidEmail() {
var email = document.getElementById(“EmailField”).value;
var submissionbutton = document.getElementById(“submitbutton”)
email = email.toLowerCase();
var AcceptedDomains = [“imc.med.sa”, “hotmail.com”, “mvrht.com”];
var domfound = false;
// Get email parts. emailName is not used, but is there in case of… the future
var emailParts = email.split("@"),
emailName = emailParts[0],
emailDomain = emailParts[1];

for (i = 0; i < AcceptedDomains.length; i++){
if(emailDomain == AcceptedDomains[i]) {
submissionbutton.disabled = false;
return true;
}
}
if (domfound == false) {
alert(“The email address you entered is invalid. Please enter a valid: NAME@imc.med.sa.”)
submissionbutton.disabled = true;
return false;
}
}
/* I WANT TO SHOW - ID Called is for a Custom Field created */
$( “#Custom87_wrapper” ).append( “Hello” );

function validate(){
var inp = document.getElementById(‘doc1’);
if(inp.files.length === 0){
alert(“Approval Application Form Attachment is Required!.”);
inp.focus();
return false;
}
}

</ script >


#5

Ok so here it looks like you are trying to use the jquery append function. You need to instantiate jquery in no conflict mode in order have access to those functions. You’ll need to include jquery from a cdn. For example Google:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
(https://developers.google.com/speed/libraries/#jquery)

Then take a look at this thread for how to instantiate jquery in no conflict mode. How to use jQuery on the client side?


#6

G’day Matt,

Thank you! :slight_smile: I added the magic of:
var $jq = jQuery.noConflict();
$jq(document).ready(function(){
//alert(“jQuery is working.”);
$jq( “#Custom87_wrapper .datalabel” ).html( “Banner : URL” );
console.log(“Yay!”)
});
It worked!.

Thank you,

Kind regards,
Rakan Bkhreba


#7

Great! Glad that got it working for you.