Skip to content

Instantly share code, notes, and snippets.

@cgcardona
Created October 29, 2010 14:16
Show Gist options
  • Save cgcardona/653627 to your computer and use it in GitHub Desktop.
Save cgcardona/653627 to your computer and use it in GitHub Desktop.
Attempting to check if an input field has a value and pass that value to a variable for use else where in the script.
function checkForInput(inputValue) {
// check to see if the form input has a value
if (inputValue === '') {
console.log('no value');
var postFunctionInputValue = inputValue;
} else {
console.log(inputValue);
var postFunctionInputValue = inputValue;
}
console.log(postFunctionInputValue);
return postFunctionInputValue;
}
$(document).ready(function() {
$("#submit-button").click(function() {
// BORDER-RADIUS
// get input value and assign to var
var newBorderRadiusValue = $("#newBorderRadiusInput").val();
// Check for input
checkForInput(newBorderRadiusValue);
var newBorderRadiusPlaceholder = 6;
// get input value and assign to var
var newBoxShadowColorValue = $("#newBoxShadowColorInput").val();
var newBoxShadowXValue = $("#newBoxShadowXInput").val();
var newBoxShadowYValue = $("#newBoxShadowYInput").val();
var newBoxShadowFadeValue = $("#newBoxShadowFadeInput").val();
var newBoxShadowValue = newBoxShadowColorValue + " " + newBoxShadowXValue + " " + newBoxShadowYValue + " " + newBoxShadowFadeValue;
// get input value and assign to var
var newTextShadowValue = $("#newTextShadowInput").val();
// change the border-radius value of #dynamic
$("#dynamic").css("border-radius", newBorderRadiusValue + "px");
// change the -webkit-box-shadow value of #dynamic
$("#dynamic").css("webkit-box-shadow", newBoxShadowValue);
// change the text-shadow value of #dynamic
$("#dynamic").css("text-shadow", newTextShadowValue);
// call refreshFooter()
refreshFooter();
}); // end of click
refreshFooter();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment