[POO] Modif value champ suite clic sur un autre
Bonjour,
Débutant en Javascript, je tente de faire un changement de valeur d' un champ, et malgré mes recherches, je n'y arrive pas.
Voilà mon code HTML/PHP :
Code:
1 2 3 4
|
echo '<a href="'.$chemin.$nom.'" title="'.$commentaire.'" onClick="fonction_hits('.$nom.');">
echo '<input type="hidden" id ="'.$nom.'" name="'.$nom.'" value="'.$hits.'">'; |
Puis ma fonction JS :
Code:
1 2 3 4 5 6 7 8
|
function fonction_hits(champ)
{
var obj = document.getElementById('champ');
var anc_hit = parseInt(obj.value);
var new_hit = anc_hit + 1;
obj.value = new_hit;
} |
Mon problème est que la value de l'input au nom "dynamique" ne change pas.
Merci pour votre aide !