Asp and javascript button direct

R

Rabel

Hi I am a novice with both asp and javascript so I may not even be
doing this correctly, but I have an asp page that has variable being
passed to it and I have a button that I need to have it go to one page
if it is one variable and another if it was the other variable. There
is only two choices but my attempts didnt work. Any direction or help
is really appreciated.

Thanks,
Randy
 
A

ASM

Rabel a écrit :
Hi I am a novice with both asp and javascript so I may not even be
doing this correctly, but I have an asp page that has variable being
passed to it and I have a button that I need to have it go to one page
if it is one variable and another if it was the other variable. There
is only two choices but my attempts didnt work. Any direction or help
is really appreciated.

I know anything about asp, but I imagine
your asp code of your asp variable could give 'true' or 'false'

<button onclick="location = (<%= aspVar %>)?
url1 : url2 ;">go to next</button>

or better
your asp variable would have to give the correct address

<button onclick="location='<%= aspVar %>';">go to next</button>
 
T

Tom Cole

Hi I am a novice with both asp and javascript so I may not even be
doing this correctly, but I have an asp page that has variable being
passed to it and I have a button that I need to have it go to one page
if it is one variable and another if it was the other variable. There
is only two choices but my attempts didnt work. Any direction or help
is really appreciated.

Thanks,
Randy

The trick is to remember that your ASP code and your Javascript
execute at entirely different times and on different machines. Your
ASP code is building your javascript code, but plays no parts in it's
execution, that happens later on the client.

It would be a lot easier if I knew what values your ASP variable could
contain and what was actually supposed to happen in each case.
But...let's assume that your ASP variable contains one of two possible
values: "Customer" and "Vendor"...
Customers go to http://website/customers/login.html and vendors go to
http://website/vendors/login.html.

I'm not an ASP developer, but a JSP developer. However they're close
enough you can probably piece it together from here:


<%
//Obtain our request parameter and assign it to 'route'
String route = request.getParameter("route");
%>

<input type="button" value="Login" onclick="document.location.href='<
%= route.equalsIgnoreCase("customer") ? "/customers/login.html" : "/
vendors/login.html" %>';"/>

HTH...
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top