Salesforce

Post date: May 10, 2016 8:32:59 PM

NGOC / rC Useful Scripts for Forms:

Inline Script (allow tab jumps):

var delay=1000;

setTimeout(function(){

names = [];

var inputs = document.getElementsByClassName("rc-field-name");

for(i =0; i < inputs.length; i++)

{ names.push(inputs[i].name); }

for(i =0; i < names.length; i++)

{ $('[name="'+names[i]+'"]').attr("tabIndex", i+1);}

}, delay);

Inline Script (limiter for 1 ticket):

setTimeout(function(){

var tickets = document.getElementsByClassName("form-control input-sm product-quantity default-quantity ui-spinner-input");

//var theQuantity1 = tickets[0].getAttribute("aria-valuenow");

//var theQuantity2 = tickets[1].getAttribute("aria-valuenow");

var upArrow = document.getElementsByClassName("ui-spinner-up")[0];

var upArrow2 = document.getElementsByClassName("ui-spinner-up")[1];

var downArrow = document.getElementsByClassName("ui-spinner-down")[0];

var downArrow2 = document.getElementsByClassName("ui-spinner-down")[1];

$(upArrow).on('click', function() {

var theQuantity1 = tickets[0].getAttribute("aria-valuenow");

if(theQuantity1 > 0)

{

tickets[1].setAttribute("aria-valuenow", "0");

}

});

$(upArrow2).on('click', function() {

var theQuantity2 = tickets[1].getAttribute("aria-valuenow");

if(theQuantity2 > 0)

{

tickets[0].setAttribute("aria-valuenow", "0");

}

});

}, 5000);

Embed Google Maps: (Somewhere in Seattle for this example)

<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d2689.8808994619653!2d-122.33212244842815!3d47.60900549570232!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x54906ab67fd786cd%3A0x9b3fd1da0445502c!2sSeattle!5e0!3m2!1sen!2sus!4v1458666646732" width=100% height="450" frameborder="0" style="border:0" allowfullscreen></iframe>

HTML Look and Feel (sets the form background to gradient blue):

<!DOCTYPE html>

<html>

<head>

<style>

html {

min-height: 100%;

}

body {

background: -webkit-linear-gradient(left, #2b506e, #24435c); /* from left to right */

background: -o-linear-gradient(right, #2b506e, #24435c); /* ending on the right */

background: -moz-linear-gradient(right, #2b506e, #24435c); /* ending on the right */

background: linear-gradient(to right, #005580, #24435c); /* moving to the right */

background-color: #2b506e; /* It's a good idea to set a background color in case the gradient doesn't load */

}

</style>

</head>

<body>

</body>

</html>

Inline Script (limiter for 1 ticket with 2 ticket prices, $18 and $180) v2:

setTimeout(function(){

//var tickets = document.getElementsByClassName("form-control input-sm product-quantity default-quantity ui-spinner-input");

var totalSum = document.getElementsByClassName(".form-control products-total-amount")[0].getAttribute("total-sum");

//alert(totalSum);

var upArrow = document.getElementsByClassName("ui-spinner-up")[0];

var upArrow2 = document.getElementsByClassName("ui-spinner-up")[1];

var downArrow = document.getElementsByClassName("ui-spinner-down")[0];

var downArrow2 = document.getElementsByClassName("ui-spinner-down")[1];

$(upArrow).blur(function() {

if(totalSum > 180)

{

alert('no good');

}

if(totalSum > 18 && totalSum > 180)

{

alert('no good');

}

});

$(upArrow2).blur(function() {

if(totalSum > 180)

{

alert('no good');

}

if(totalSum > 18 && totalSum > 180)

{

alert('no good');

}

});

}, 5000);

Inline Java to stop the back key to re-enter data and mess up the form

if(window.location.href.indexOf("&data") > 0){

window.location.href = window.location.href.substr(0, window.location.href.indexOf("&data"));

window.location.reload();

}