-1

The form element on my page created with ASP.NET looks as such (if I do "View page source" from a web browser):

< form method="post" 
       action="Page.aspx?lang=en-US&amp;pp=10&amp;bi=10" 
       id="ctl01" enctype="multipart/form-data">

How do I access that form element? I need to remove &amp;pp=10&amp;bi=10 part from the action element?

Mudassir Hasan
  • 28,083
  • 20
  • 99
  • 133
c00000fd
  • 20,994
  • 29
  • 177
  • 400
  • do you want to access this in javascript? – K D Mar 05 '13 at 10:18
  • 1
    So you have *some code* that is generating some HTML and you want to change the HTML that is being generated? It is really hard to say how to do that without seeing the *some code*. ASP.NET has various different ways to do it (WebForms (shudder) and MVC work completely differently). – Quentin Mar 05 '13 at 10:20
  • @JørnSchou-Rode: I'm not exactly sure how the answer for that post would work in my case. – c00000fd Mar 05 '13 at 10:33

1 Answers1

1

if you just have one form on the page then try this in your javascript

alert(document.forms[0].action);

to change the action just do it like this

var actionPath = document.forms[0].action;
// your logic to remove unwanted string with the help of string functions in JS
document.forms[0].action = actionPath;

In case you know what is the name of your form then access it like this.

document.forms['YOUR_FORM_NAME'].action

or you can access it with the client id as well if you want consiering your form have runat="server with it

document.getElementById(....)// Client Id of the form control
K D
  • 5,889
  • 1
  • 23
  • 35