I have a input from website which defines like this:
<input type="text" name="postdb[title]" size="60" value id="title" class="input_text">
I’ve tried this:
document.getElementsByName('postdb[title]')[0].value='test'
and this:
document.getElementById('title').value='test'
but it doesn’t work,how to set the value of this input use javascript?
edit:
I found that this input is insideof <form name="FORM..,so how to find it in that form use javascript?
edit:solved;
its actually inside of FORM from iframe,so I just use this:
var vform =document.frames['main'].document.forms['FORM'];
vform.elements['title'].value='test'; thanks for help,
Your DOM was probably not loaded yet.
The above example will fail because we are trying to search an element that has not yet loaded. A mistake easily made!
By running the javascript after the required DOM has loaded, we are able to find it.