i am new to javascript and i have been trying things out lately . but i am stuck here in one function which return the error :
[10:55:47.027] NS_ERROR_XPC_BAD_CONVERT_JS: Could not convert JavaScript argument arg 0 [nsIDOMHTMLFormElement.appendChild] @ http://localhost/myproj/test5.html:15
Now let me explain what the code does :
1) i have defined a function called “add” it takes one argument which is a arary of strings.
when it is called , the function creates a new form and new input’s with type “text” and value the same as each string in the argument array.
here is the code :
function add(index_array) {
//create the form
var myform = document.createElement("form");
myform.id="k_form"
for ( i =0 ; i <index_array.length ; i ++)
{
var mytext = document.createElement("input");
mytext.tpye="text";
mytext.value="index_array[i]";
mytext.id="index_array[i]";
myform.appendChild("mytext");
console.log("error");
}
mydiv=document.getElementById("d_div");
mydiv.appendChild("myform");
}
now when i execute it , i get the error displayed above , i cant figure out my mistake can anyone please help with that.
thanks a ton!
You are trying to append a string to your form not the node variable
should be
Also
should be