Forum Moderators: open

Message Too Old, No Replies

Accessing Forms in DIV

Accessing Forms in DIV, The Content of DIV is populated dynamically

         

abanip

10:06 am on Jan 14, 2002 (gmt 0)



I've a DIV(id=A) element, whose content is getting changed dynamically(depending on actions, from other DIV-say X) using
document.all["A"].innerHTML = document.all["X"].innerHTML.

Now if the DIV(id=X) element has a form with a textbox, How to access the value of Textbox in Javascript?

Content of DIV (id=X)
<form name=myForm>
<input type=text name=myText value='Hello'>
</form>

knighty

10:17 am on Jan 14, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hey abanip, and welcome to Webmaster World!

In IE its just the same as if it were a normal form
with Netscape you have to tell it that the form is in a DIV by:

document.layers["name_of_layer"].document.forms["name_of_form"]

and then the rest of the form info tagged on the end

joshie76

1:06 pm on Jan 14, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just use the standard method referencing the form itself instead of the div

document.forms['formname'].textboxname.value

If you have multiple forms in multiple DIVs then make sure you give each form a unique name so that you can ensure you access the correct one. This is assuming I understand your problem which I may not. If I'm going off on a tangent you may want to post a code snippet or stickyMail me the URL so I can have a look at what you're trying to do in full.

J