I have followed this Question to get all inputs value into one input value and it's working fine: Clone multiple input values into one input field
Working fiddle: https://jsfiddle.net/yt4qeo6k/
jQuery(document).ready(function($){
$(function(){
$('.copy').on('keyup blur', function(){
var bgcolor = $(".bgcolor").val();
var textcolor = $(".textcolor").val();
var padding = $(".padding").val();
var linkcolor = $(".linkcolor").val();
$('.full').val( '#masthead {background-color:' + bgcolor + ';color:' + textcolor + ';padding:' + padding + 'px;} #masthead a{color:' + linkcolor + ';}');
}).blur();
});
});
// Body Classes
function setting_dynamic_body_classes() { ?>
<input type="text" name="dynamic-bg-color" data-alpha="true" data-default-color="" class="bgcolor copy color-picker" value="">
<input type="text" name="dynamic-text-color" data-alpha="true" data-default-color="" class="textcolor copy color-picker">
<input type="range" name="dynamic-padding" class="rangeslider padding copy" value="" step="1" min="0" max="100">
<input type="text" name="dynamic-link-color" data-alpha="true" data-default-color="" class="linkcolor copy color-picker">
<input type="text" name="dynamic-body-classes" id="dynamic-body-classes" value="" data-alpha="true" data-default-color="" class="full" style="width:100%;"/><br>
<strong>current Value: </strong><?php echo get_option('dynamic-body-classes'); ?>
<?php }
the Field dynamic-body-classes is saved in a custom options page in Wordprsss. Now the issue after saving the form in Wordpress the Inputs value is empty because only the field "dynamic-body-classes" was saved in the database.
and the value of "dynamic-body-classes" e.g will look like following:
#masthead {background-color:#1e73be;color:#dd9933;padding:95px;} #masthead a{color:#81d742;}
How can i add the value of each field (dynamic-bg-color, dynamic-bg-color, dynamic-padding, dynamic-link-color ) based on the value "dynamic-body-classes" ?
before changing the values of each field
after changing the values of each field
After Saving the form the current value is showing up as expected but the dynamic field are empty
I am not sure i am doing this the right way, but what i need is to add many dynamic fields that their value get saved as css in one field for dynamic Theme styling.