INOH INOH - 4 months ago 6x
Javascript Question

Input values into html form using javascript

I am having difficulty figuring out where i am going wrong. Ihave searched the internet for several hours with no luck. this is my situation. I am running a mobile device app, i am loading a form (locally) into iframe. iam then (onload) trying to insert values into my forms textbox. here is the codes

<iframe name="myframe"id="myframe"
width=480px height=400px frameborder=1></iframe>

and the javascript function

function imLoaded(){
var ifrm = document.getElementById('myframe');
var form = doc.getElementById('updateform');
form.document.getElementById("updateform").user.value = 'hello';


Try this

var iframe = document.getElementById('myframe');
var innerDoc = (iframe.contentDocument) ? iframe.contentDocument : iframe.contentWindow.document;

you can use innerDoc with getElementById to get any element of id

Hope this will help you.