1

The value is null

html input code and javasript:

var tanggal1 =  document.getElementById("tanggal1").value;
var tanggal2 =  document.getElementById("tanggal2").value;
alert(tanggal1);

I expected the output tanggal1 = <input type='date' name='tanggal1' id='tanggal1'/> value

5
  • 1
    Can you post your HTML code? Commented Sep 18, 2019 at 7:33
  • 1
    Post your HTML code, too Commented Sep 18, 2019 at 7:33
  • Where is your HTML? Commented Sep 18, 2019 at 7:33
  • I am voting to close this as off-topic because the problem cannot be reproduced without the HTML code. The question does not contain a minimal reproducible example. Commented Sep 18, 2019 at 8:00
  • What are you actually asking? Commented Sep 18, 2019 at 9:35

2 Answers 2

1

HTML:

<input type="text" name="name" id="tanggal1" value="value" />

JS:

var tanggal1 = document.getElementById("tanggal1").value;

Sign up to request clarification or add additional context in comments.

Comments

0

HTML:

<!DOCTYPE html>
<html>
 <head>
  <title>Test</title>
</head>
<body onload="test();">
    <input type="text" name="name" id="tanggal1" value="value">
    <script>
        function test()
        {
           alert(document.getElementById('tanggal1').value);
        }
    </script>
</body>
</html>

Test result

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.