Skip to main content
2 of 4
added 22 characters in body
Shomz
  • 146
  • 4

It should only work with elements that have a name, and a value, and it should ignore "hidden". However some of the elments do not have a type flag, so I can't do something like input.attr('type').toLowerCase() != 'hidden'.

After that, it ignores any field with the class element_reference_input, and looks for fields with form-control or question_textarea_input.

You can put all that in a single if-statement and it doesn't even have to look bad (you can probably format it a bit more to your liking):

if (input.val() && 
    input.attr('name') && 
    (
      !input.attr('type') ||
       input.attr('type').toLowerCase() != 'hidden'
    ) &&
    input.attr('class') &&
    input.attr('class').indexOf('element_reference_input') == -1 &&
    (  
      input.attr('class').indexOf('form-control') > -1 || 
      input.attr('class').indexOf('question_textarea_input') > -1 
    )
){
        objOutgoingData.push(
            {
                name:'' + input.attr('name').split('.').pop(),
                value:'' + input.val(),
                table:'' + tableName,
            }
        );
 }
Shomz
  • 146
  • 4