Populate hidden text input with custom attributes from radio button

jQuery(document).ready(function($){

//this populates the hidden text inputs with the event details
jQuery(‘#input_2_1’).change(function(){
var datetime = jQuery(‘input[name=”input_1″]:checked’, this).attr(‘datetime’);
var venue = jQuery(‘input[name=”input_1″]:checked’, this).attr(‘venue’);
var address = jQuery(‘input[name=”input_1″]:checked’, this).attr(‘address’);
var city = jQuery(‘input[name=”input_1″]:checked’, this).attr(‘city’);
var state = jQuery(‘input[name=”input_1″]:checked’, this).attr(‘state’);
var zip = jQuery(‘input[name=”input_1″]:checked’, this).attr(‘zip’);

jQuery(‘#input_2_11’).val( datetime );
jQuery(‘#input_2_12’).val( venue );
jQuery(‘#input_2_13’).val( address );
jQuery(‘#input_2_14’).val( city );
jQuery(‘#input_2_15’).val( state );
jQuery(‘#input_2_16’).val( zip );

})
});

Leave a Reply