I have a strange issue with this very small code :
function autre(element)
{
if (element.value=="autre")
{
var inputText=document.createElement("input");
inputText.setAttribute("type", "text");
inputText.setAttribute("name", "autre");
inputText.setAttribute("required", "");
element.parentNode.appendChild(inputText);
}
else element.parentNode.removeChild(element.nextSibling);
}
and HTML
<select name="matiere" onchange="autre(this);">
<option value="autre">Autre</option>
<option value="...">Some others options</option>
</select>
Wich create an input text when the 'autre' value of a select is selected.. This works fine.. But when I change the value again I get a weird error: object is not a function..
Any idea ?..
Edit : The problem was as ceakki mentionned the name of the function. Thanks! Thank you everybody for your help