Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Cannot read properties of null (reading 'value') from document.getElementById

I wish to read the value of this input field.

<input type="text" name="acadp_fields[1200]" class="text" placeholder="" value="December 26, 1969">

My code is this.

document.getElementById("acadp-upload-file-ipfs").addEventListener("click", function(event) {
    event.preventDefault()

    document.getElementById("acadp-upload-file-ipfs").removeAttribute("href");

    document.getElementById("loading").innerHTML = '<div class="acadp-spinner"></div>';

    const dateOfBirth = document.getElementById('acadp_fields[1200]').value;

    ...
    ...

But I’m getting the error below when I click the element acadp-upload-file-ipfs

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Uncaught TypeError: Cannot read properties of null (reading 'value')

What am I doing wrong?

>Solution :

Try This

document.getElementsByName("acadp_fields[1200]")[0].value

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading