Re: Change the Form action

From: Bob Barrows [MVP] (reb01501_at_NOyahoo.SPAMcom)
Date: 01/31/05


Date: Mon, 31 Jan 2005 10:06:54 -0500

MichaelK wrote:
> Just a few comments to your example.
> It works indeed, but only when you have id attribute in the form or
> input tags.
> Unfortunately I just wanted to make a few quick fixes to existing
> pages, which don't have them
> (ofcourse I could add).

If you only have one form on a page, you can reference the form by its
ordinal index rather than its id/name:

document.forms(0).action

> But again it also works only when you have <script
> language="VBScript">,

That is what you seemed to be asking for ...

> and not working on asp pages when using just <%
> %> blocks of the code.

If you wanted a server-side solution, you should have said so. It would have
been very easy to respond:
Changing the Form action after submission is not possible using server-side
code.

> But here was my fault

Definitely

> I wasn't clear about
> what I was looking for. I just hate
> to use <script language="VBScript">, because it's available on the
> page source
> for anybody.

You cannot respond to client-side events without using client-side code.
Period.
You cannot change DHTML properties (such as the form's action property)
without using client-side code. Period.

> And the last even I add the id attribute and use <vbscript...> it
> doesn't work in
> Netscape at all.

Netscape does not support client-side vbscript. Netscape only supports
javascript in client-side code. Why did you ask for a client-side vbscript
solution if you expected users to be using Netscape? Oh that's right, you
didn't think that's what you were asking for.

You have fallen into the trap of thinking that vbscript is server-side and
javascript is client-side. Change your thinking. With ASP, both jscript and
vbscript can be used in server-side code. With IE, both vbscript and jscript
can be used in client-side code. In Netscape with no plugin, only javascript
can be used in client-side code.

The distinction is "server-side vs. client-side," not "vbscript vs
javascript". You will get more appropriate help if you use the proper
terminology.

Since you want to validate using server-side code, you will need to put the
validation code where it will run after the form is submitted. Without
client-side code it will be impossible to change a form's action property on
submission. You can use Server.Transfer or Response.Redirect in server-side
code based on the content of the submission.

A better newsgroup for server-side asp questions is
microsoft.public.inetserver.asp.general.

Bob Barrows

-- 
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


Relevant Pages

  • Re: Bugs in VBScript GetRef()
    ... ASP is server-side technology. ... client-side code so I don't even know if it does anything if run on the ... Bob Barrows ... This email account is my spam trap so I ...
    (microsoft.public.inetserver.asp.general)
  • Re: Running server-side code from a javascript click event
    ... XSL there is some javascript commands that are attached to certain HTML ... (because I can't generate server-side controls in XSL), ... subroutine which is server-side. ... client-side code do a postback. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: store javascript value from window.open in session variable
    ... > way to do this is to store this javascript variable in a session variable. ... It seems that you mix server- and client-side code in your discourse. ... variable accessible mainly on server-side. ... With best wishes, Arthur Nesterovsky ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Same vbscript code to use in several HTML pages
    ... Are you talking about server-side code or client-side code? ... HTH, ... > I've written some code in vbscript that I would like to include in several ... > html pages. ...
    (microsoft.public.frontpage.programming)
  • Re: Basic Question
    ... vbscript is only supported for client-side code in IE. ... Dim response ... Please reply to the newsgroup. ...
    (microsoft.public.scripting.vbscript)

Loading