Results 1 to 4 of 4

Thread: Can you switch on Submit buttons?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    ma,usa
    Posts
    485
    Hi,
    I'm really liking this stuff now, but lots of questions. How can I do a select case or If statement to determine what action goes in the form tag? I want to use more than one submit button on my calling html page to determine which ASP page to call. I want to use "real" buttons, not one's I have to make by pics or tables.
    Thanks

  2. #2
    Guest
    Hi, why not try anything like this:

    --------------------------------------------------
    <script language="javascript">
    <!--
    function whereto( )
    {
    if (condition)
    {
    window.parent.location.href = "destination1.asp";
    }
    else
    {
    window.parent.location.href = "destination2.asp";
    }
    }
    //-->
    </script>

    <form action="whatever.asp" onsubmit="whereto()">
    ---------------------------------------------------

    Good luck!

  3. #3
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    try this:


    whatever.html
    Code:
    <html>
    
    <head>
    <script language=javascript>
    function doit(x)
    {
    	
    	switch(x)
    	{	
    		case 1:
    			document.frm1.action="some.asp";
    			break;
    		case 2:
    	
    			document.frm1.action="someother.asp";
    		break;
    	}
    
    document.frm1.submit();
    }
    </script>
    </head>
    
    <body>
    
    <form name=frm1>
    	<input name=txt1>
    	<input name=txt2> 
    </form>
    <form name=frm2>
    	<input type='button' name=but1 onClick="doit(1)" value="Submit to choice 1">
    	<input type='button' name=but2 onClick="doit(2)"value="Submit to choice 2"> 
    </form>
    
    </body>
    
    </html>
    someother.asp

    Code:
    <%@ Language=VBScript %>
    <HTML>
    <HEAD>
    
    </HEAD>
    <BODY>
    
    <h1>someother asp</h1>
    <%
    
    
    response.write("Text 1: " & request("txt1") & "<BR>")
    response.write("Text 2: " & request("txt2") & "<BR>")
    
    
    
    %>
    
    
    </BODY>
    </HTML>

    some.asp
    Code:
    <%@ Language=VBScript %>
    <HTML>
    <HEAD>
    
    </HEAD>
    <BODY>
    
    <h1>some asp</h1>
    <%
    response.write("Text 1: " & request("txt1") & "<BR>")
    response.write("Text 2: " & request("txt2") & "<BR>")
    %>
    
    </BODY>
    </HTML>
    Mark
    -------------------

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    ma,usa
    Posts
    485
    Thanks!
    I'm liking this even more now! YEE-HAA!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width