Skip to content

Instantly share code, notes, and snippets.

@jindrichsirucek
Created December 31, 2017 06:06
Show Gist options
  • Save jindrichsirucek/ded6d5883907c84599149db3a441e54e to your computer and use it in GitHub Desktop.
Save jindrichsirucek/ded6d5883907c84599149db3a441e54e to your computer and use it in GitHub Desktop.
Javascript + jquery
$("#newOrderFormElement").keydown(function (e) {
//console.log(e.keyCode);
if (e.metaKey && e.keyCode === 68) //Command + Alt + d
{
fillFormByDebugValues();
event.preventDefault();
}
});
function fillFormByDebugValues()
{
var form = jQuery("#newOrderFormElement");
form.find("input[name='name']").val("Jindra");
form.find("input[name='email']").val("@gmail.com");
form.find("input[name='telephone']").val("");
form.find("select[name='gender']").val("muž");
form.find("textarea[name='message']").val("Automaticky předvyplněno");
form.find("input[name='city']").val("Brno");
form.find("select[name='country']").val("Česká Republika");
var selects = form.find("select");
selects.each(function( index )
{
var $options = $(this).find('option');
var random = ~~(Math.random() * $options.length);
$options.eq(random).prop('selected', true);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment