Display javascript value inside HTML object

I have the following relevant code in the header of my html document:

test1.value = System.Gadget.Settings.read("Date1");

And I'm trying to display the value of test1 in the body of my html document.

Displayed when I use:

<input type="text" id="test1" />

But it does not work when I use (in the body):

<script type="text/javascript">
    document.write(document.getElementById('test1').id);
</script>

Any suggestions would be greatly appreciated.

+3
source share
2 answers

This may be obvious, but why not just write:

<html>
  <body>
    <div>Here the Date1 value: 
      <script type="text/javascript">
        document.write(System.Gadget.Settings.read("Date1"));
      </script>
    </div>
  </body>
</html>

If this does not do what you want, explain what your expected result is.

+7
source

, script , os 1 . , script, .

- ...

<html>
  <body>
    <input type="text" id="test1" />
    <script type="text/javascript">
      document.write(document.getElementById('test1').id);
    </script>
  </body>
</html>
0

Source: https://habr.com/ru/post/1709057/


All Articles