JAVASCRIPT MESSAGE D4ERREUR

Résolu
layeures Messages postés 286 Date d'inscription   Statut Membre Dernière intervention   -  
Alain_42 Messages postés 5361 Date d'inscription   Statut Membre Dernière intervention   -
Bonjour,

j ai un site de referencement que j ai essayer d ameliorer mes probleme il mache un message d erreur



Message : 'document.getElementById(...)' a la valeur Null ou n'est pas un objet.
Ligne : 893
Caractère : 1
Code : 0

le probleme c est que je ne veut pas mettre de formulaire alors j ai fait ca

echo "<script language=\"javascript\">\n";

for ($i=0;$i<$nb2;$i++){

echo "var form = document.createElement(\"forms\");\n";
echo "form.setAttribute(\"action\", \"".$form1[$i][0]."\");\n";
echo "form.setAttribute(\"method\", \"".$form1[$i][1]."\");\n";
echo "form.setAttribute(\"name\", \"".$form1[$i][2]."\");\n";
echo "form.setAttribute(\"id\", \"".$form1[$i][2]."\");\n";
echo "form.setAttribute(\"target\", \"unframe\");\n";

echo "var ".$textboxtotal[$i][0]." = document.createElement(\"input\");\n";
echo "".$textboxtotal[$i][0].".setAttribute(\"type\", \"hidden\");\n";
echo "".$textboxtotal[$i][0].".setAttribute(\"name\", \"".$form1[$i][3]."\");\n";
echo "".$textboxtotal[$i][0].".setAttribute(\"value\", \"".$nom."\");\n";
echo "form.appendChild(".$textboxtotal[$i][0].");\n";

echo "var ".$textboxtotal[$i][1]." = document.createElement(\"input\");\n";
echo "".$textboxtotal[$i][1].".setAttribute(\"type\", \"hidden\");\n";
echo "".$textboxtotal[$i][1].".setAttribute(\"name\", \"".$form1[$i][4]."\");\n";
echo "".$textboxtotal[$i][1].".setAttribute(\"value\", \"".$prenom."\")\n";
if ($form1[$i][5] != ""){
echo "var ".$textboxtotal[$i][1]." = document.createElement(\"input\");\n";
echo "".$textboxtotal[$i][1].".setAttribute(\"type\", \"hidden\");\n";
echo "".$textboxtotal[$i][1].".setAttribute(\"name\", \"".$form1[$i][5]."\");\n";
echo "".$textboxtotal[$i][1].".setAttribute(\"value\", \"".$titre."\");\n";
echo "form.appendChild(".$textboxtotal[$i][1].");\n";
}
if ($form1[$i][6] != ""){
echo "var ".$textboxtotal[$i][2]." = document.createElement(\"input\"); \n";
echo "".$textboxtotal[$i][2].".setAttribute(\"type\", \"hidden\");\n";
echo "".$textboxtotal[$i][2].".setAttribute(\"name\", \"".$form1[$i][6]."\");\n";
echo "".$textboxtotal[$i][2].".setAttribute(\"value\", \"".$url."\");\n";
echo "form.appendChild(".$textboxtotal[$i][2].");\n";
}
if ($form1[$i][7] != ""){
echo "var ".$textboxtotal[$i][3]." = document.createElement(\"input\");\n";
echo "".$textboxtotal[$i][3].".setAttribute(\"type\", \"hidden\");\n";
echo "".$textboxtotal[$i][3].".setAttribute(\"name\", \"".$form1[$i][7]."\");\n";
echo "".$textboxtotal[$i][3].".setAttribute(\"value\", \"".$email."\");\n";
echo "form.appendChild(".$textboxtotal[$i][3].");\n";
}
if ($form1[$i][8] != ""){
echo "var ".$textboxtotal[$i][4]." = document.createElement(\"input\");\n";
echo "".$textboxtotal[$i][4].".setAttribute(\"type\", \"hidden\");\n";
echo "".$textboxtotal[$i][4].".setAttribute(\"name\", \"".$form1[$i][8]."\");\n";
echo "".$textboxtotal[$i][4].".setAttribute(\"value\", \"".$description."\");\n";
echo "form.appendChild(".$textboxtotal[$i][4].");\n";
}

echo "var ".$textboxtotal[$i][5]." = document.createElement(\"selected\");\n";
echo "".$textboxtotal[$i][5].".setAttribute(\"name\", \"".$form1[$i][9]."\");\n";
echo "".$textboxtotal[$i][5].".setAttribute(\"value\", \"".$menu[$i]."\");\n";
echo "form.appendChild(".$textboxtotal[$i][5].");\n";

echo "var ".$textboxtotal[$i][6]." = document.createElement(\"input\");\n";
echo "".$textboxtotal[$i][6].".setAttribute(\"type\", \"hidden\");\n";
echo "".$textboxtotal[$i][6].".setAttribute(\"name\", \"".$form1[$i][10]."\");\n";
echo "".$textboxtotal[$i][6].".setAttribute(\"value\", \"".$login."\");\n";
echo "form.appendChild(".$textboxtotal[$i][6].");\n";

echo "var ".$textboxtotal[$i][7]." = document.createElement(\"input\");\n";
echo "".$textboxtotal[$i][7].".setAttribute(\"type\", 'text');\n";
echo "".$textboxtotal[$i][7].".setAttribute(\"name\", \"".$form1[$i][11]."\");\n";
echo "".$textboxtotal[$i][7].".setAttribute(\"value\", \"".$passe."\");\n";
echo "form.appendChild(".$textboxtotal[$i][7].");\n";

if ($form1[$i][7] != ""){
echo "var ".$textboxtotal[$i][8]." = document.createElement(\"input\");\n";
echo "".$textboxtotal[$i][8].".setAttribute(\"type\", \"hidden\");\n";
echo "".$textboxtotal[$i][8].".setAttribute(\"name\", \"".$form1[$i][12]."\");\n";
echo "".$textboxtotal[$i][8].".setAttribute(\"value\", \"".$motscle."\");\n";
echo "form.appendChild(".$textboxtotal[$i][8].");\n";
}
// le reste son des valeur cacher par defaut
if ($form1[$i][13] != ""){
echo "var ".$textboxtotal[$i][9]." = document.createElement(\"input\");\n";
echo "".$textboxtotal[$i][9].".setAttribute(\"type\", \"hidden\");\n";
echo "".$textboxtotal[$i][9].".setAttribute(\"name\", \"".$form1[$i][13]."\");\n";
echo "".$textboxtotal[$i][9].".setAttribute(\"value\", \"".$form1[$i][14]."\");\n";
echo "form.appendChild(".$textboxtotal[$i][9].");\n";
}

if ($form1[$i][15] != ""){
echo "var ".$textboxtotal[$i][10]." = document.createElement(\"input\");\n";
echo "".$textboxtotal[$i][10].".setAttribute(\"type\", \"hidden\");\n";
echo "".$textboxtotal[$i][10].".setAttribute(\"name\", \"".$form1[$i][15]."\");\n";
echo "".$textboxtotal[$i][10].".setAttribute(\"value\", \"".$form1[$i][16]."\");\n";
echo "form.appendChild(".$textboxtotal[$i][10].");\n";
}
if ($form1[$i][17] != ""){
echo "var ".$textboxtotal[$i][11]." = document.createElement(\"input\");\n";
echo "".$textboxtotal[$i][11].".setAttribute(\"type\", \"hidden\");\n";
echo "".$textboxtotal[$i][11].".setAttribute(\"name\", \"".$form1[$i][17]."\");\n";
echo "".$textboxtotal[$i][11].".setAttribute(\"value\", \"".$form1[$i][18]."\");\n";
echo "form.appendChild(".$textboxtotal[$i][11].");\n";
}
if ($form1[$i][19] != ""){
echo "var ".$textboxtotal[$i][12]." = document.createElement(\"input\");\n";
echo "".$textboxtotal[$i][12].".setAttribute(\"type\", \"hidden\");\n";
echo "".$textboxtotal[$i][12].".setAttribute(\"name\", \"".$form1[$i][19]."\");\n";
echo "".$textboxtotal[$i][12].".setAttribute(\"value\", \"".$form1[$i][20]."\");\n";
echo "form.appendChild(".$textboxtotal[$i][12].");\n";
}
if ($form1[$i][21] != ""){
echo "var ".$textboxtotal[$i][13]." = document.createElement(\"input\");\n";
echo "".$textboxtotal[$i][13].".setAttribute(\"type\", \"hidden\");\n";
echo "".$textboxtotal[$i][13].".setAttribute(\"name\", \"".$form1[$i][21]."\");\n";
echo "".$textboxtotal[$i][13].".setAttribute(\"value\", \"".$form1[$i][22]."\");\n";
echo "form.appendChild(".$textboxtotal[$i][13].");\n";
}
if ($form1[$i][23] != ""){
echo "var ".$textboxtotal[$i][14]." = document.createElement(\"input\");\n";
echo "".$textboxtotal[$i][14].".setAttribute(\"type\", \"hidden\");\n";
echo "".$textboxtotal[$i][14].".setAttribute(\"name\", \"".$form1[$i][23]."\");\n";
echo "textbox16.setAttribute(\"value\", \"".$form1[$i][24]."\");\n";
echo "form.appendChild(".$textboxtotal[$i][14].");\n";
}

}

MALGRE LE FAIT QUE J AI FAIT document.createElement(\"forms\");\n
IL ME DIT QUE L OBJET EST NULL OU INEXITANT

COMMENT FAIRE POUR RESOUDRE LE PROBLEME

MERCI D'AVANCE DE VOTRE REPONSE
A voir également:

1 réponse

Alain_42 Messages postés 5361 Date d'inscription   Statut Membre Dernière intervention   894
 
document.getElementById(...)

il te dit que c'est l'objet que tu essaye d'atteindre par son id

hors dans la génération de ton formulaire tu mets bien les attributs type, name, value mais pas id

echo "var ".$textboxtotal[$i][0]." = document.createElement(\"input\");\n";
echo "".$textboxtotal[$i][0].".setAttribute(\"type\", \"hidden\");\n";
echo "".$textboxtotal[$i][0].".setAttribute(\"name\", \"".$form1[$i][3]."\");\n";
echo "".$textboxtotal[$i][0].".setAttribute(\"value\", \"".$nom."\");\n";
echo "form.appendChild(".$textboxtotal[$i][0].");\n";
0