jeudi 1 octobre 2015

Javascript. Pretick form checkbox on page load without an id

Simply put i am trying to pretick a checkbox on pageload but the checkbox cant be targeted via an id as it does not have one and its not possible for me to modify form code. The checkbox is the only checkbox present in the form if that helps.

I already have a body on load event - its it possible to use getElementsByName? if so i can target the checkbox with that, but just not sure how to set the field to be ticked

<script type="text/javascript">
 function onLoadBody()
 {
     document.getElementsByName('checkboxName').??????????????
 }
</script>
</head>
<body onload="onLoadBody();">

any help appreciated

Regards, Chris




Aucun commentaire:

Enregistrer un commentaire