console.log me renvoie undefined
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| <form method="post" action="backend/settingRights.php">
<div class="formFlex">
<input type="hidden" name="right[]">
<input type="hidden" name="right[]">
<fieldset class="settings"><legend>Définition des droits des utilisateurs</legend>
<label><span>Utilisateur</span><?= $lstUser; ?></label><br>
<label><span>Nom</span><?= $echo['fullname']; ?></label><br>
<label><span>Catégorie</span><?= $echo['rightlevel']; ?></label><br>
<div>
<fieldset class="rights"><legend>Pages ou fonctionnalités</legend>
<fieldset><legend>Droits d'accès sur le fichier</legend>
<label><input type="image" src="images/0.png" alt="btn" name="img[]"><span>Sélections et navigation</span></label><br>
<label><input type="image" src="images/0.png" alt="btn" name="img[]"><span>Onglet adresse</span></label><br>
</fieldset>
</fieldset>
</div>
</fieldset>
</div>
</form> |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| const
thisForm = document.querySelector("form")
,user = thisForm.user
,main = document.querySelector(".noDispl")
,btns = document.querySelectorAll("input[type='image']")
;
//console.log(document.Location.href); // undefined
if(btns.length){
btns.forEach(function(curBtn, index){
curBtn.addEventListener('click',function(e){
console.log(thisForm);
let path = e.target.src;
let begin = path.substring(0,path.indexOf('.png')-1);
let imgNb = path.charAt(path.length-5);
imgNb++;
if(imgNb > 2)
imgNb = 0;
e.target.src= begin+imgNb+'.png';
console.log(thisForm.right); // undefined
//thisForm.right[index] = imgNb;
//alert(e.target.src);
}, false );
});
} |
Je ne comprends pourquoi la ligne 21 renvoie undefined. (Ni d'ailleurs la ligne 8 que j'ai contournée dans mon code.)