By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,467 Members | 1,308 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,467 IT Pros & Developers. It's quick & easy.

Asp and javascript button direct

P: n/a
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

Mar 15 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/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>
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Mar 16 '07 #2

P: n/a
On Mar 15, 4:19 pm, "Rabel" <R...@Creativeness.comwrote:
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...

Mar 16 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.