form name

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hey all,
is there a way to get the name of my form element in javascript?
thanks,
rodchar
 
Hi Rod,

Here's some code that might get you started.

Let us know if this helps?

Ken
Microsoft MVP [ASP.NET]

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
Label1.Text = Me.Form.ClientID
End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Get the form name</title>
<script language="javascript" type="text/javascript">
function GetFormName()
{
var frm = document.forms[0].name;
alert(frm);
}

</script>
</head>
<body onload="GetFormName();">
<form id="form1" runat="server">
<div>
<asp:label id="Label1" runat="server" text="Label"></asp:label>
</div>
</form>
</body>
</html>
 
thanks Ken i'll give it a try and report back.

Ken Cox said:
Hi Rod,

Here's some code that might get you started.

Let us know if this helps?

Ken
Microsoft MVP [ASP.NET]

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
Label1.Text = Me.Form.ClientID
End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Get the form name</title>
<script language="javascript" type="text/javascript">
function GetFormName()
{
var frm = document.forms[0].name;
alert(frm);
}

</script>
</head>
<body onload="GetFormName();">
<form id="form1" runat="server">
<div>
<asp:label id="Label1" runat="server" text="Label"></asp:label>
</div>
</form>
</body>
</html>

rodchar said:
hey all,
is there a way to get the name of my form element in javascript?
thanks,
rodchar
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top