Hari, Form name won't work, or won't be reliable, since two forms have the same name (via Struts). You MUST use the index.
Caroline (or Jen?) All I can say is "Wow!" document.getElementById() only works in IE, not FF. Your response is an arduous elaboration of my document.forms[0] and document.forms[1], which is the correct solution. If I don't completely understand the problem I typically ask for more information or I don't respond. Any attempt to solve the problem, without first knowing what it is, leads to confusion on the part of the poster. On 8/1/06, Caroline Jen <[EMAIL PROTECTED]> wrote:
1. Each element in a document must have a unique id. This element is then accessed in script using document.getElementById(). e.g. <p id="myP">...</p> --> document.getElementById("myP") If more than one element has the same id and you try to use that id with document.getElementById(), the method doesn't know which element you're talking about, and an error results. 2. <form name="findUsers"> <--> document.forms["findUsers"] or document.findUsers <form id="findUsers"> <--> document.getElementById("findUsers") 3. Only form elements have a value attribute. Only form elements can pass a value with a form when the form is submitted. <a> is not a form element. Example: <form name="myForm"> <input name="myField" type="text" value="something"> <input name="myOtherField" type="text" value="something-else"> <input name="mySubmit" type="submit" value="Click to Submit"> </form> Assuming that this is the first or only form in the page: The form can be referenced as: document.forms[0] document.getElementsByTagName("form")[0] document.forms["myForm"] document.forms.myForm document.myForm document.getElementsByName("myForm")[0] All but the first two of these require that the form have a name attribute whose value is "myForm". An id attribute will not work for this. Now, let's assume that we set a variable theForm equal to one of these references to the form whose name (not id) is "myForm". The first input in this form can then be referenced as any of the following: theForm.elements[0] theForm.getElementsByTagName("input")[0] theForm.elements["myField"] theForm.elements.myField theForm.myField theForm.getElementsByName("myField")[0] All but the first two of these require the the input have the name (not id) "myField". Similarly, the second input can be accessed as any of the following: theForm.elements[1] theForm.getElementsByTagName("input")[1] theForm.elements["myOtherField"] theForm.elements.myOtherField theForm.myOtherField theForm.getElementsByName("myOtherField")[0] All but the first two of these require the the input have the name (not id) "myOtherField". You can give a form or form element element an id attribute and then access it using document.getElementById() as well as getElementsByTagName(). However, you cannot use the id attribute value for forms and element array references. Suppose you have this: <form id="myForm"> <!-- ...form elements... --> </form> Then none of these references will work for the form: document.forms["myForm"] document.forms.myForm document.myForm In each case, you'll get an error saying that the object reference is null, undefined, or isn't an object. The exact wording of the message depends on which browser you're using, but they all mean the same thing: "I've no idea what you're talking about". This appears to be the root of your problem. The short version: Give name attributes to all your form and form element tags. You should do this in any case, since serverside scripts don't read id's. You needn't bother with an id attribute for a form or form element unless you want to (a) access it in a script by means of document.getElementById() or (b) you want to style it using a CSS id selector (e.g. form#myForm or #myForm). --- Li <[EMAIL PROTECTED]> wrote: > Hi, > > Would it be possible if you can combine two form to > one but have two > object behind to accept the dat from form you > submit? > > > On 8/1/06, Krishna, Hari <[EMAIL PROTECTED]> > wrote: > > pass the formbean name at run time change the > logic It works for me:) > > > > -----Original Message----- > > From: Parvat Singh Ranawat > [mailto:[EMAIL PROTECTED] > > Sent: Monday, July 31, 2006 11:32 PM > > To: user@struts.apache.org > > Subject: two form one jsp > > > > > > Hi all, > > > > I'm attempting to create a JSP that is made up of > two forms. Each > > form needs a same form bean and is processed by a > same > > action. The catch is that the one form comes from > Header (This will be > > there for all the pages as part of left panel ) > > > > and second is coming from my jsp and problem > occures while calling JAVA > > SCRIPT > > > > ie > > 1) if I use document. form[0] then this always > points to the first form > > (which is there in Header) > > 2) if I use document.formName > > then there is ambiguity which form to call. > > > > so how to work in this situation > > > > > > Thanks > > > > Shakti > > Notice: All email and instant messages (including > attachments) sent to > > or from Franklin Templeton Investments (FTI) > personnel may be retained, > > monitored and/or reviewed by FTI and its agents, > or authorized > > law enforcement personnel, without further notice > or consent. > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: > [EMAIL PROTECTED] > > For additional commands, e-mail: > [EMAIL PROTECTED] > > > > > > > -- > When we invent time, we invent death. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: > [EMAIL PROTECTED] > For additional commands, e-mail: > [EMAIL PROTECTED] > > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]