0

I am running a code that scrapes a form and then opens a new browser tab with the data using the format: fieldID, fieldLabel, filedValue

jQuery(document).ready(function(){jQuery('#helpdesk_ticket_submit').on('click', function(e){
  submitText = "<table class='table'>"
  submitText += `  <thead>
                    <tr>
                      <th scope="col">fieldID</th>
                      <th scope="col">fieldLabel</th>
                      <th scope="col">fieldValue</th>
                    </tr>
                  </thead>
                  <tbody>`
  
  jQuery('#new_helpdesk_ticket input, #new_helpdesk_ticket select, #new_helpdesk_ticket textarea').each(
    function(index){  
        var input = jQuery(this);
        if (input.prev().is('textarea'))
          if (input.attr('class').indexOf('hide') >= 0) 
            return;
        let label =  extractLabelText(input.attr('id')) //extrenal function to get the label of the field
        submitText += "<tr><td>" + input.attr('id') + "</td><td>" + label  + "</td><td> " + input.val() + "</td></tr>"
    }
    
  );

  window.open().document.write(submitText);

there is nothing wrong with the code. My question is when I do window.open().document.write(submitText); how can I format the table with bootstrap?

  • https://stackoverflow.com/questions/2685614/load-external-css-file-like-scripts-in-jquery-which-is-compatible-in-ie-also is probably close to what you want to do. – user2263572 Sep 14 '20 at 16:07
  • What if you started submitText out with a link to bootstrap css delivered from a CDN? Would that accomplish what you want? `submitText = ''` – John Harper Sep 14 '20 at 20:21

0 Answers0