Link to home
Start Free TrialLog in
Avatar of Wayne Barron
Wayne BarronFlag for United States of America

asked on

ASP inside JavaScript (runat=Server)

Hello All;

How do I get this to work?

<%if getType="Article" then%>
case '[ct':return '<tr><th class="wikibox">Article Views</th><td class="wikibox">'+artHits+'</td></tr>';
<%elseif getAdmin="EditArticle" then%>
case '[ct':return '<tr><th class="wikibox">Article Views</th><td class="wikibox">Hits Generated</td></tr>';
<%end if%>

Open in new window


If keeps giving me an error on the "Article"

Microsoft JScript compilation error '800a03ed'
Expected '('
/Test.asp, line 203
if getType="Article" then
----------------^

Thanks All;
Carrzkiss
Avatar of pateljitu
pateljitu
Flag of Canada image

If you are using Javascript as code behind, try this syntax

<%if (getType=="Article") then%>
Avatar of Wayne Barron

ASKER

I am using VBScript, but have a JS code that is runat:Server
So, not really sure what would need to be used within it.

I have done the following
<%if (getType=="Article") then%>
case '[ct':return '<tr><th class="wikibox">Article Views</th><td class="wikibox">'+artHits+'</td></tr>';
<%elseif (getAdmin=="EditArticle") then%>
case '[ct':return '<tr><th class="wikibox">Article Views</th><td class="wikibox">Hits Generated</td></tr>';
<%end if%> 

Open in new window

And when run, I get an error on the <%

Microsoft JScript compilation error '800a03ea'
Syntax error
/Test.asp, line 204

Removing the <% and %>
from the code, I get an error on the
else if

if (getType=="Article") then
case '[ct':return '<tr><th class="wikibox">Article Views</th><td class="wikibox">'+artHits+'</td></tr>';
else if (getAdmin=="EditArticle") then
case '[ct':return '<tr><th class="wikibox">Article Views</th><td class="wikibox">Hits Generated</td></tr>';
end if

Open in new window


Microsoft JScript compilation error '800a03ea'
Syntax error
/Test.asp, line 206

else if (getAdmin=="EditArticle") then
^

Also.
I would need to end the statement, but it does not seem like the

end if

is going to work, or does it?
SOLUTION
Avatar of pateljitu
pateljitu
Flag of Canada image

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
ASKER CERTIFIED SOLUTION
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
I took my code and did what I new how to do, I used my vbscript at the top of the page outside of the JS code, and then called the Variable inside of it code.

Works like expected, should have done this to begin with.
Thanks  pateljitu for you trying to help.

Carrzkiss