Last active
August 29, 2015 14:22
-
-
Save StephaneTy-Pro/67504682aadf5743cfc6 to your computer and use it in GitHub Desktop.
A form filler (for testing purpose)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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