0

I am using weblogic 8.1.6. My problrm is I have a parent page that is using Ajax to call a child page. The Child page is executed Into the Parent Page. Parent page has a form and a javascript function to read all the elements of the form but the javascript function is not able to read the elements of child page. I am using " form.elements[i].name " which is working fine in IE but not in firefox and chorme . What should i use to read the element of child page that is executed inside parenPage.

parent code

<form id="Tab">  
   <input type="button" onclick="alert('calling AjaX Method');" value="ADD" />  
   <div id="ChildOutputWillDisplayedHere"></div>
</form>`  

childCode

<input class="FormFields" type = "text" name = "NameID" value = "">
<a href="#" onclick="callingJavscriptFunction()">click Me </a>`

javascript code

callingJavscriptFunction(){
    var form = document.forms['tab'];
    for(var i=0; i<form.elements.length; i++) 
    {
        var fieldName = form.elements[i].name;
    }
}  
Sudhir Bastakoti
  • 99,167
  • 15
  • 158
  • 162
Mavenkp
  • 27
  • 1
  • 2
  • 6
  • This might be helpfull: https://developer.mozilla.org/en/DOM/document.forms – Teemu Apr 23 '12 at 10:01
  • Thanks . but i have used same code. i have only 1 form that is in d parent page and with d FF i am not able to access d elements of child page that is executed inside d form of d parent page. javascript code part that worked in IE but not in FF ......................................var form = document.forms[getNetuiTagName("tabView",this)];........................... for(var i=0; i – Mavenkp Apr 23 '12 at 10:33
  • Please add code-snippets of the form and script to your question. There won't be a reference to the element, because you're assingning it's name to `fieldName`. I can't understand, how this code would work in IE either. – Teemu Apr 23 '12 at 10:53
  • parent code eg:
    Child code : click Me
    – Mavenkp Apr 23 '12 at 10:56
  • Again: Please add the code of the form and script to your question, not in a comment. – Teemu Apr 23 '12 at 11:01
  • javascriptFunction : callingJavscriptFunction(){ var form = document.forms['tab']; for(var i=0; i – Mavenkp Apr 23 '12 at 11:02

1 Answers1

0

It seems, that IE gives you all input-elements in the form, even if they didn't have name-attribute. Your input in Tab however lacks the name-attribute, which you try to read in the function. AFAIK this code will assign undefined to fieldName in IE also.

Looping like this will assign only the name of the last element in the elements-collection to your fieldName-variable. No problem with one input-element, but if there are more...

Teemu
  • 22,918
  • 7
  • 53
  • 106