hidden field 'is null or not an object'

F

Foehammer

I've created a WYSIWYG HTML editor. I have an ImageButton whose
onClick event is supposed to set the value of a hidden form field
called txtHTML to the HTML content of an IFRAME called editor.

Here's the code that is supposed to set the value:
document.EditorForm.HTMLEditor_txtHTML.value =
editor.document.body.innerHTML;

I'm getting this error.
Microsoft JScript runtime error: 'document.EditorForm.txtHTML' is null
or not an object

Anybody have any ideas on this one?

Will
 
V

Victor Garcia Aprea [MVP]

Hi Foehammer,

This is apparently your code.
Is this the exact error text for sure?

Note that one line lists _txtHTML while the other has txtHTML, these are NOT
the same members.

--
Victor Garcia Aprea
Microsoft MVP | ASP.NET
Looking for insights on ASP.NET? Read my blog:
http://obies.com/vga/blog.aspx

To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
 
V

Vidar Petursson

Hi

document.forms["FORMNAME"].FIELDNAME.value =
document.frames["IFRAMENAME"].document.body.innerHTML;

Or
<form name="blah">
<input type="hidden" name="myHidden">
<input type="image"
onclick="this.form.myHidden.value=document.frames["IFRAMENAME"].document.body.innerHTML">
</form>

Case sensitive

You may also want to check if the iframe is there and it's readyState:
if(document.frames["IFRAMENAME"])
{
if(document.frames["IFRAMENAME"].document.readyState == "complete") doIt();
else doSomethingElseLikeRe_CheckInXTimeAndGiveErrMsgAfterXTries();
}
else doSomethingElseLikeRe_CheckInXTimeAndGiveErrMsgAfterXTries();

More info:
http://msdn.microsoft.com/library/d...hor/dhtml/reference/dhtml_reference_entry.asp

--
Best Regards
Vidar Petursson
==============================
Microsoft Scripting MVP
http://www.microsoft.com/technet/scriptcenter
==============================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top