Skip to content

Instantly share code, notes, and snippets.

View noahub's full-sized avatar
💻
Doing computer stuff

Noah noahub

💻
Doing computer stuff
View GitHub Profile
@noahub
noahub / redirect_w_params.html
Created August 27, 2015 22:18
Redirect with URL parameters
<script>
var yourURL = 'http://www.google.com/';
var newURL = yourURL + location.search;
window.location = newURL;
</script>
@noahub
noahub / url_param_grab.html
Created September 18, 2015 20:53
Parameter Grabber
<script>
var getUrlParameter = function getUrlParameter(sParam) {
var sPageURL = decodeURIComponent(window.location.search.substring(1)),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
@noahub
noahub / params_field_values.html
Created September 18, 2015 21:34
Grab Parameters and set form field values
<script>
//Function that stores parameters in array, returns parameter value
var getUrlParameter = function getUrlParameter(sParam) {
var sPageURL = decodeURIComponent(window.location.search.substring(1)),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === sParam) {
@noahub
noahub / us_code.html
Created October 2, 2015 17:29
US State Code Value Map
<script>
lp.jQuery(function($){
// The dropdown's ID (without #)
var id = 'state';
// Map of old to new values
var values = {
@noahub
noahub / field_to_upper_case.html
Last active October 2, 2015 23:10
Field Values to Upper Case
<script>
//Replace #lp-pom-form-17 with your form's ID and 'email' with your field name.
//To convert field values to lower case, simply replace 'toUpperCase()' with 'toLowerCase()'
//To convert field values to Title Case, simply replace 'toUpperCase()' with 'replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});'
$("#lp-pom-form-17 input[name=email]").val(function () {
return this.value.toUpperCase();
})
</script>
//To execute the above function on form submit, use @johnnyopao's script like so:
@noahub
noahub / lb_redir.html
Last active October 7, 2015 16:24
Lightbox Main Page Redirect
<script>
window.top.location.href = "http://www.example.com";
</script>
@noahub
noahub / append_params_text.html
Created October 8, 2015 20:22
Append incoming parameters to text links on page
//The following script can be placed in the javascripts section of your page with placement 'Before Body End Tag'
<script>
$(function() {
$('.lp-pom-text a').not('a[href^=#]').each( function() {
this.href = this.href + window.location.search;
});
});
</script>
@noahub
noahub / current_month.html
Last active February 23, 2017 12:21
Replace Target Text with Current Month
<script>
$(function() {
var month = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ];
var d = new Date();
var n = month[d.getMonth()];
$( "#month" ).text(n);
});
</script>
@noahub
noahub / autocomplete.html
Last active June 5, 2019 08:09
Autocomplete Snippet
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#map {
height: 100%;
}
</style>
@noahub
noahub / button_click_value.html
Created November 5, 2015 19:02
Populate form field value based on different button clicks
//Update the button IDs (e.g. '#lp-pom-button-126') with your own button IDs, 'your_field_name' with your form's field name, and the value (e.g. 'Intro') with your own values.
<script type="text/javascript">
$(document).ready(function () {
$("#lp-pom-button-126").click(function(){
$("#lp-pom-form-363 input[name=your_field_name]").val("Intro");
});