Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 138192

Why is only one property being printed

$
0
0

I'm working on a project with Google Apps Scripts that use the scriptProperties service to save text a user inputs and print what was input last when the program is opened later. The problem I'm running into is it's only printing the most recently saved value and the others are not printing out as expected. ONLY the most recently saved property.

Here's what I'm working with.

This is the HTML document.

<html>
  <head>
    <base target="_top">
    <script>
      <? var data = sendData(); ?> 
    </script>
  </head>
  <body>
    <? if (data.title !== "undefined") { ?>
        <input value="<?= data.title ?>" type="text">
      <? } else { ?>
        <input value="" type="text">
    <? } ?>

    <? if (data.url !== "undefined") { ?>
        <input value="<?= data.url ?>" type="text">
      <? } else { ?>
        <input value="" type="text">
    <? } ?>

    <? if (data.desc !== "undefined") { ?>
      <input value="<?= data.desc ?>" type="text">
    <? } else { ?>
      <input value="" type="text">
    <? } ?>

  </body>
</html>

And here is what i have in the JS file.

function sendData() {
  var data = PropertiesService.getScriptProperties().getProperties();
  return data;
  }

So for example, if I saved something to data.title, then data.desc would show up as undefined (it also sometimes shows up as blank) even though I have a property saved there. If I rewrite data.desc, then data.title would show up as empty.

Any ideas why this might be occurring?

PS. This is obviously not the full program but I shortened it to where I'm running into issues.


Viewing all articles
Browse latest Browse all 138192

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>