Link to home
Start Free TrialLog in
Avatar of wjindra
wjindra

asked on

Using javascript switch and need to use <ahref on actions

I am writting a large if / else tree in an existing website.  My include libraries have to be put into the html program using a scripting language called SpeedScript.  These includes bring in the login data that I am testing in my if tree.  Instead of using the if/else I am trying a switch.

I need to know how to write this if/else tree / switch statement.  I am brand new to Javascript.  Here is the code I currently have that is not working.  The actions are to open a customers indivitual Excel spreadsheet.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<HTML>
<HEAD>
<TITLE>eSales Center - Customer Links</TITLE>
<META HTTP-EQUIV="Cache-Control" CONTENT="No-Cache">
<META HTTP-EQUIV="Pragma" CONTENT="No-Cache">
<META HTTP-EQUIV="Expires" CONTENT="0">


<SCRIPT LANGUAGE="SpeedScript">

{shared/esalesvars.i}
{shared/validate-session.i}
{shared/pp-global.i}

assign cLogin = if trim(cLogin) = "" then get-value("operinit") else cLogin.

</SCRIPT>
</HEAD>
<BODY>
<SCRIPT LANGUAGE="javascript">

switch (cLogin)
{
     case "12102":
          <a href="/WI_testweb/12102.xls"><b><font size="3">Matrix</font></b></a><br />
          break
     case "134965":
          <a href="/WI_testweb/12102.xls"><b><font size="3">Matrix</font></b></a><br />
          break
     case "13953":
          <a href="/WI_testweb/12102.xls"><b><font size="3">Matrix</font></b></a><br />
          break
     case "13716":
          <a href="/WI_testweb/13716.xls"><b><font size="3">Matrix</font></b></a><br />
          break
     case "111667":
          <a href="/WI_testweb/111677.xls"><b><font size="3">Matrix</font></b></a><br />
            break
     default:
                window.alert("This account does not have a custom matrix");
 }
</SCRIPT>
</BODY>
</HTML>
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Try this :

The following open the excel file in a popup window
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE>eSales Center - Customer Links</TITLE>
<META HTTP-EQUIV="Cache-Control" CONTENT="No-Cache">
<META HTTP-EQUIV="Pragma" CONTENT="No-Cache">
<META HTTP-EQUIV="Expires" CONTENT="0">
<SCRIPT LANGUAGE="SpeedScript">
{shared/esalesvars.i}
{shared/validate-session.i}
{shared/pp-global.i}
assign cLogin = if trim(cLogin) = "" then get-value("operinit") else cLogin.
</SCRIPT>
</HEAD>
<BODY>
<SCRIPT LANGUAGE="javascript">
	window.onload = function() {
		switch (cLogin) {
			case "12102":
				window.open("/WI_testweb/12102.xls","Excel");
				break;
			case "134965": 
				window.open("/WI_testweb/12102.xls","Excel");
				break;
			case "13953":
				window.open("/WI_testweb/12102.xls","Excel");
				break;
			case "13716": 
				window.open("/WI_testweb/13716.xls","Excel");
				break;
			case "111667":
				window.open("/WI_testweb/111677.xls","Excel");
				break;
			default:
				window.alert("This account does not have a custom matrix");
		}
	}
</SCRIPT>
</BODY>
</HTML>

Open in new window

Avatar of wjindra
wjindra

ASKER

This did not work.
ASKER CERTIFIED SOLUTION
Avatar of wjindra
wjindra

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
OK good, I don't understood you want to put the right link in your page