Skip to content

Instantly share code, notes, and snippets.

@StephaneTy-Pro
Last active August 29, 2015 14:22
Show Gist options
  • Save StephaneTy-Pro/67504682aadf5743cfc6 to your computer and use it in GitHub Desktop.
Save StephaneTy-Pro/67504682aadf5743cfc6 to your computer and use it in GitHub Desktop.
A form filler (for testing purpose)
(function( window ) {
var document = window.document,
fieldValueMap = {
'addressName' : 'Mon Adresse'
//, 'owner_counrty' : 'France'
, 'city' : 'Lille'
, 'postalCode' : '59000'
, 'addressLine4' : 'Bâtiment ou étage'
, 'owner_further_address_details' : 'Compl. Adresse' // id
//, 'owner_further_moving_date_month' : '01'
//, 'owner_further_moving_date_year' : '2015'
};
Object.keys( fieldValueMap ).forEach(function( name ){
var input = document.querySelector( "form input[name=" + name + "]" )
|| document.querySelector( "form textarea[name=" + name + "]" );
input && ( input.value = fieldValueMap[ name ] );
});
Object.keys( fieldValueMap ).forEach(function( id ){
var input = document.querySelector( "form input[id=" + id + "]" )
|| document.querySelector( "form textarea[id=" + id + "]" );
input && ( input.value = fieldValueMap[ id ] );
});
})( window );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment