Re: two form one jsp
http://www.w3.org/TR/REC-DOM-Level-1/level-one-html.html#ID-36113835 On 8/1/06, Monkeyden <[EMAIL PROTECTED]> wrote: 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. 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. ... --> > 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. <--> > document.forms["findUsers"] or > document.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. > > is not a form element. > > Example: > > > > value="something-else"> > > > > 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: > > > > > > 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 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: two form one jsp
Hi All n Kalpesh, Here I can use seperate formBean but this may not be good practice... actually somebody suggested me to pass the form object as parameter in function while calling java script like
Re: two form one jsp
Is it not possible to use two seperate form beans? -Kalpesh - How low will we go? Check out Yahoo! Messengers low PC-to-Phone call rates.
Re: two form one jsp
hi , The problem in using document.form[0]. and document.form[1] for first and second form respctively first form comes from Header.jsp and second form from myFoo.jsp and Header is there through out Application and the functionality that is part of Header that I need to write in myFoo.jsp there i need to pass same actionForm (This is where problem occured). And also i want myFoo.jsp as part of some Popup functionality where there is no Header.jsp included so in that case we have single form so document.form[1] will not work please suggest Thanx Shakti On 02/08/06, Monkeyden <[EMAIL PROTECTED]> wrote: Can we please stop suggesting use of the form name? It.will.not.work. If both forms have the same name, it makes a reference to document.forms ['foo'] an array and not a reference to the form. Of course you *could *do this: function tellMe(){ alert("Form 1: " + *document.forms['foo'][0].form2Text.value*); alert("Form 2: " + *document.forms['foo'][1].form2Text.value*); } but A, that would be stupid, and B, you have to use the index value anyway. On 8/1/06, kalpesh modi <[EMAIL PROTECTED]> wrote: > > I am not sure whether > > document. form['formName'] will work or not. Give it a try. > > -Kalpesh > > > > - > Yahoo! Music Unlimited - Access over 1 million songs.Try it free. >
Re: two form one jsp
Can we please stop suggesting use of the form name? It.will.not.work. If both forms have the same name, it makes a reference to document.forms['foo'] an array and not a reference to the form. Of course you *could *do this: function tellMe(){ alert("Form 1: " + *document.forms['foo'][0].form2Text.value*); alert("Form 2: " + *document.forms['foo'][1].form2Text.value*); } but A, that would be stupid, and B, you have to use the index value anyway. On 8/1/06, kalpesh modi <[EMAIL PROTECTED]> wrote: I am not sure whether document. form['formName'] will work or not. Give it a try. -Kalpesh - Yahoo! Music Unlimited - Access over 1 million songs.Try it free.
Re: two form one jsp
I am not sure whether document. form['formName'] will work or not. Give it a try. -Kalpesh - Yahoo! Music Unlimited - Access over 1 million songs.Try it free.
Re: two form one jsp
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. ... --> 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. <--> document.forms["findUsers"] or document.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. is not a form element. Example: 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: 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
Re: two form one jsp
1. Each element in a document must have a unique id. This element is then accessed in script using document.getElementById(). e.g. ... --> 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. <--> document.forms["findUsers"] or document.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. is not a form element. Example: 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: 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. > > > > >
Re: two form one jsp
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]
RE: two form one jsp
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]
Re: two form one jsp
Your example WILL always point to the first form, since you use the index of 0 (zero). You need to use 1 to point to the second form. This works fine for me: function tellMe(){ alert("Form 1: " + document.forms[0].form2Text.value); alert("Form 2: " + document.forms[1].form2Text.value); } On 7/31/06, Parvat Singh Ranawat <[EMAIL PROTECTED]> wrote: 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
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