<script type="text/javascript">
$('#addForm :input').each(function() {
var id = $(this).attr('id');
if (!id) return; // skip elements without an ID
var tag = this.tagName.toLowerCase();
var type = $(this).attr('type');
var value;
// Handle checkboxes/radios
if (type === 'checkbox' || type === 'radio') {
value = $(this).is(':checked') ? $(this).val() : '';
} else {
value = $(this).val();
}
// Escape quotes in value
value = value.replace(/"/g, '\\"');
// Build line based on element type
if (tag === 'select') {
console.log(`$("#${id}").val("${value}").trigger('change');`);
} else {
console.log(`$("#${id}").val("${value}");`);
}
});
</script>