mercredi 3 août 2016

javascript checkbox document.getElementById returns null

Stupid small script that does not work perfectly after I added 2 checkboxes. Objective is to open an URL with some dynamic parameters. I googled to find possible error, but I don't find. DOM property is declared before the script as requested.

any idea ? thank you

<body>
<table border="0">
    <tr>
        <td>Serial Number</td>
        <td><input type="text" id="deviceUdid" value="251528003720" maxlength="12" size="10"></td>
    </tr>
    <tr>
        <td>HouseHold</td>
        <td><input type="checkbox" id="Household" value="1"></tr>
    <tr>
        <td>Community</td>
        <td><input type="checkbox" id="Communities"></tr>
    <tr>
        <td><input type="button" id="btn" value="Submit" onClick="form_submit()"></tr>
</table>

<script type="text/javascript">
    function form_submit() {
        var a = 'https://test?';
        a += 'ACTION=authenticateUniqueDevice';
        a += '&deviceUdid=' + document.getElementById('deviceUdid').value;
        a += '&CONTENT_READ_KEY=dddddddddd';
        if (document.getElementById('HouseHold').checked) a += '&includeHousehold=true';
        if (document.getElementById('Communities').checked) a += '&includeHouseholdCommunities=true';
        window.open(a, 'MyWindow', 'width=600,height=700');

    }
</script>




Aucun commentaire:

Enregistrer un commentaire