I'm getting the form is not defined error when is useform.parentNode.appendChild(iframe);inside a javascript function, I don't know why.

Any suggestions?

if i understand your code you want to add iframe to an exsiting form. if that is so
than try this. if it work tell me
var useform = document.getElementById("your forms id");
before you can use the useform

Don't think the OP is adding an iframe element to the form, but adding it to the form's parent element. But your suggestion is valid that using getElementById() function to obtain the element from the DOM.

Anyway, back to the OP... Do you have a form tag name "form"?

@ i get you Taywin. i thing his function is not working becasue of the form. you must refreen you form tag's name. that is (form tag's name).parentNode.appendChild(iframe)
i am right @ Taywin