How do I access a <form> that is not the master page <form>?

Posted by VBCSharp on Stack Overflow See other posts from Stack Overflow or by VBCSharp
Published on 2010-03-18T15:11:51Z Indexed on 2010/03/18 15:41 UTC
Read the original article Hit count: 182

Filed under:
|
|

Winforms developer converting to web developer. I know the part about the Master Page having the tag, what is not clear is if I can or can not have another in one of my content pages. I have been seeing both answers doing searches. I see yes you can if only one has runat=server. The thing is I have a that contains several radio buttons on a web page that has a master page. I have a .js file that has a function if I send the name into it, it will loop thru the controls in the form to see which one is selected and return the desired date horizon(MTD, QTD, YTD, etc.). When I run this on a non master page web page it works fine. However, when I run on a web page that has a master page I can't seem to get to the element. I tried getElementByID, I tried looping through the page elements, etc. Maybe I am going about this incorrectly and I hope someone can straighten me out.

Here is the code from my .js file that may help explain what I am trying to do a little better.

var frmDateRanges = document.getElementById(formFieldName); 
var chosen;
var len = frmDateRanges.DateRanges.length;
for(i=0;i<len;i++) 
   {
    if(frmDateRanges.DateRanges[i].checked) 
      {
        chosen = frmDateRanges.DateRanges[i].value;
       }
    }

where formFieldName is an arguement that is passed into the function and DateRanges is the name value given to the radio buttons.

In the button I call this function I have: onclick ="FunctionCall('frmDateRanges')" FunctionCall is just for description purposes, 'frmDateRanges' is the name and id given to the form action=""

Thanks for the help as I am stumped at this point. If there is a better way to do this please let me know that as well.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about .NET