Linking CSS and HTML in Apps Script using the include method

I'm facing a challenge in adding a CSS file to an HTML form within an Apps Script without deploying the project as a Web App. I have been trying to use the include function to apply the CSS style, but I always end up with the script appearing above my form. It seems like the include might not be placed correctly, but I am unsure of where it should go. My HTML page is named Formulaire.html, the CSS file is css.html, and the Google Apps Script file is onOpen.gs.

Below is the code snippet from onOpen.gs:

function onOpen() {
 SpreadsheetApp.getUi()
      .createMenu('Formulaire')
      .addItem('Compléter', 'openForm')
      .addToUi();
}

function openForm() {

  var html = HtmlService.createHtmlOutputFromFile('Formulaire')
    .setWidth(1500)
    .setHeight(1000);
    SpreadsheetApp.getUi()
    .showModalDialog(html, 'Saisissez les informations nécessaires');
}

function include(filename) {
  return HtmlService.createHtmlOutputFromFile(filename)
      .getContent();
}
body {
    font-family: Arial, sans-serif;
    background-color: #1a237e;
}
<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
    <meta charset="UTF-8>
    <base />
         <?!= include('css'); ?>
  </head>
  <body>

    <!-- MEANS -->
    <div class="category">
      <label for="inputMeans" class="ds-formcontrol-label">Means</label>
      <div style="width:100%;">
        <ul class="display-list" id="displayMeans"></ul>
        <input type="text" class="ds-input" id="inputMeans" list="datalistMeans" placeholder="Select here">
        <datalist id="datalistMeans"></datalist>
      </div>
    </div>
</body>
</html>

If you have any suggestions on how to resolve these issues, I would greatly appreciate it. Thank you!

Answer №1

Give this a shot:

function initiateForm() {

  var formContent = HtmlService.createTemplateFromFile('Form').evaluate()
    .setWidth(1500)
    .setHeight(1000);
    SpreadsheetApp.getUi()
    .showModalDialog(formContent, 'Enter the necessary information');
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

"Troubleshooting a malfunctioning PHP contact form that is not functioning properly

Here's some of my JavaScript code: var form = $('#main-contact-form'); form.submit(function(event){ event.preventDefault(); var form_status = $('<div class="form_status"></div>'); $.ajax({ url: $(th ...

Preventing the element from breaking when it is not the child: Tips and Tricks

In order to align both .quote-container and #new-quote elements in the same line, even when the window width is very small (e.g., 83 pixels), I used min-width on the .quote-container element successfully. However, applying the same technique to the #new-qu ...

Uploading a file to a server using HTML and PHP: a step-by-step guide

Looking to utilize PHP as a proxy for uploading files to a server. Any advice on how I can send the uploaded files along with a Basic Authorization header? ...

Difficulty in aligning tables with absolute positioning in Internet Explorer compared to Chrome

Encountering an issue with the alignment of elements when using position: absolute; across multiple browsers. In Chrome, everything appears properly aligned within the table. Refer to the following link for a visual: https://i.sstatic.net/qhrAi.jpg Howe ...

Choosing a class using CSS

Can someone please help me with editing this HTML code using CSS? I'm trying to target the coupon divs using #coupon but it doesn't seem to be working. Any assistance would be greatly appreciated. <div class="coupon"> <h1>Classic ...

Exploring the Limitless Possibilities of Bootstrap 5 Horizontal Scrolling

Each time I create a new page, there is a slight horizontal scrolling issue that occurs. When the page scrolls horizontally, it leads to a white space where nothing exists beyond the footer and header at the edge of the screen. Even though it's just a ...

What is the best approach to designing the style of HTML elements that have embedded PHP codes within them?

I have created a PHP file to fetch data from a database and display it in a tabular format. <html> <head> <title>Admin</title> <link rel="stylesheet" type="text/css" href="adminPanel.css"/> </head> <body&g ...

Discover the following element with a specific class within the AngularJS framework

I need help locating the following tr element with a specific class from the current tr in AngularJS. If the immediate next tr does not have the class "opened", I want to target the next tr with the "opened" class. How can I achieve this in AngularJS? tem ...

jQuery Failing to Work

I'm experimenting with creating a falling effect for a DIV element when a piece of text is hovered over. The original effect can be seen here. var $dropDiv = $('#dropDiv'); $('#holder p').on('hover', function () { // ...

Overflow-x in HTML5 Websites

I recently launched my website in the "alpha" stage - I have implemented full mobile support using media queries. It displays perfectly when the browser window is resized, but I noticed a strange space to the right of everything on my Samsung Galaxy Note ...

Leveraging Selenium to extract text from a dynamically populated DIV using JavaScript

I am currently utilizing Selenium to automatically retrieve all comments from a New York Times article. Once the comments are loaded, my goal is to extract them and save the information for future use. However, upon inspecting the source code of the articl ...

How come the image height isn't working in a bootstrap column?

Why is the tomato picture taller than the others even though I specified the height and width? It must be something simple: <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/> <div class="conta ...

Issue: An unwanted horizontal scrollbar is generated upon inserting an image into a column using the Bootstrap 4 grid system

As a complete beginner in coding and web development, I'm facing a problem that I need help solving: I attempted to insert an image into the column within my Bootstrap 4 grid layout. However, upon adding the image, a horizontal scrollbar mysteriously ...

When dynamically adding rules to jQuery validate, I encountered an unexpected error

My dynamic form validation with jQuery validate involves a drop-down menu on my HTML that includes values 1, 2, 3, and 4. Depending on the selection made from the drop-down, different div elements are displayed with corresponding fields. All the input fie ...

Changing the CSS property of a ul tag in HTML: A step-by-step guide

Currently, I am utilizing the Slide functionality of Bootstrap with jQuery and CSS. Everything is running smoothly without any issues. Here is the source code I am working with: <div id="photos" class="tabcontent"> <div id="ninja-slider"> ...

Altering the background colour of dropdown fields when clicking on a checkbox

How can I make the colors of my dropdown fields match the colors of the text (non-dropdown) fields when they are disabled using a checkbox? This is how my code looks: <form v-on:submit.prevent :disabled="isDisabled(opti ...

The custom attribute in jQuery does not seem to be functioning properly when used with the

I am currently working with a select type that includes custom attributes in the option tags. While I am able to retrieve the value, I am experiencing difficulty accessing the value of the custom attribute. Check out this Jsfiddle for reference: JSFIDDLE ...

Is it possible to incorporate both a file input and text input within a single form?

Is there a way to incorporate both a file input and text input into the same form? Appreciate your help in advance ...

Acquire the stripe color scheme of Bootstrap tables

I have a Razor component that populates a series of divs within a container. Is there a way to utilize the table-striped color scheme for my odd divs without replacing it entirely? Alternatively, if I create a new CSS class called "Div-Stripe-Row." Can ...

The 'formGroup' property cannot be bound in the LoginComponent because it is not recognized as a valid property of the 'form'

When working on my Angular project and using ReactiveFormsModule to create a form, I encountered an error message during the build process. The specific error was: src/app/security/login/login.component.html:11:13 - error NG8002: Can't bind to ' ...