Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8303889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:39:07+00:00 2026-06-08T17:39:07+00:00

Trying to do some clean programming in Google Apps Script. Does anyone know how

  • 0

Trying to do some clean programming in Google Apps Script. Does anyone know how to reuse oft-repeated method/property chains? Example:

var lblDate = app.createLabel("Date")
    .setId('lblDate')
    .setStyleAttribute("fontFamily", "\"Helvetica Neue\", \"HelveticaNeue\", Helvetica,   Arial, \"Lucida Grande\", sans-serif")
    .setStyleAttribute("fontSize", "14px")
    .setStyleAttribute("fontSize", "1.4rem")
    .setStyleAttribute("lineHeight", "1")
    .setStyleAttribute("color", "#222222")
    .setStyleAttribute("position", "relative");

This question has many implications for me, but the task at hand (above) is applying Zurb Foundation styles across various form elements using only GAS Javascript.

Any takers?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T17:39:08+00:00Added an answer on June 8, 2026 at 5:39 pm

    Could you do something like:

    function applyCSS(element, style) {
      for (var key in style) {
        element.setStyleAttribute(key, style[key]);
      }
    }
    
    var _zurb1 = 
      {
        "fontFamily": "\"Helvetica Neue\", \"HelveticaNeue\", Helvetica,   Arial, \"Lucida Grande\", sans-serif",
        "fontSize": "14px",
        "fontSize": "1.4rem",
        "lineHeight": "1",
        "color": "#222222",
        "position": "relative"
      }
    

    And then in your main code:

    var lblDate = app.createLabel("Date").setId('lblDate');
    applyCSS(lblDate, _zurb1);
    

    All credit for this method to James Ferreira, author of Google Script (Enterprise Application Essentials).


    edit (4/09/2012)

    With the new setStyleAttributes() method I think you can now do away with the applyCSS() function and just use:

    var lblDate = app.createLabel("Date").setId('lblDate').setStyleAttributes(_zurb1);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to clean up some of the JavaScript throughout my views and
I'm trying to clean up some warnings in some old Java code (in Eclipse),
I am trying to clean up some data that has been incorrectly entered. The
We just moved over to Git from SVN. In trying to clean up some
I am trying to clean up some cloned repositories I have, basically converting clones
Recently I'm trying to reuse some UI elements in my application. When I started
I am trying to get started with some basic Ocaml programming. To start I
I'm trying to clean some HTML with libtidy (C language), the problem is: I
I'm trying to clean some warnings in my C# project, and I've a couple
I've been trying to Google and find some guides or heads-up on how to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.