[thelist] accessing a form within a div created on-the-fly

Peter-Paul Koch ppk at xs4all.nl
Mon Aug 14 06:02:24 CDT 2000


<div name='datadiv1'>
    <form name='listDetails'>
        <input name='messageBox' type='text' value=''>
    </form>
</div>

I've tried various things unsuccessfully; here's a few of them:

    document.body.all.item(divId).forms(0).messageBox.value
    document.body.all.item(divId).all.item(forms(0)).messageBox.value
    document.body.all.item(divId).all(forms(0).messageBox.value

If someone could point out where I'm going wrong here, I'd greatly
appreciate it!!

***

Frankly, I don't understand your code. 'forms(0)' is certainly wrong, it
should be 'forms[0]' because 'forms' is an array. Don't know about the
'item()' thing, it should be 'item[]' anyway but I thought it didn't work.

For forms and images you don't need to go through the advanced DOM's
(document.all, document.layer etc.). Simply doing

document.forms['listDetails'].messageBox.value

works fine, except in Netscape 4 when 'datadiv1' has a 'position' defined,
then you have to do

document.layers['datadiv1'].document.forms['listDetails'].messageBox.value

ppk




More information about the thelist mailing list