Expand|Select|Wrap|Line Numbers
- <%
- Function FFcolor(x)
- Select case x
- case 1: FFcolor = "#FF0000"
- case 2: FFcolor = "something else"
- etc.
- End Function
- %>
Expand|Select|Wrap|Line Numbers
- <a ... style="color: <%=FFcolor(x)%>; ... >
But I can't find a similar way to call a javascript function like this
Expand|Select|Wrap|Line Numbers
- <script type="text/javascript">
- function FFcolor(x) {
- switch (x) {
- case 1: return "#FF0000";
- case 2: return "something else";
- etc. }
- }
- </script>
Expand|Select|Wrap|Line Numbers
- <a ... style="color: [ javascript function call?]; ... >
Since I already have functions setup to do this for events (mouseover, etc) I want to use the same functions for initializing a new page (like a refresh). In other words, the color changes from some previous color when the page is presented, conditioned on a "pagename" variable, then changes onmouseover, and changes back to the first color onmouseout (without any onclick action). Each page starts out with its unique font color.
The mouseover & mouseout, and "I wish" the startup font color results should be based on the same function using the same "switch" subfunction.
I can use the first example, <%= %> for the startup color but not for the events (because of some further manipulation I do); and that means I have to have similar routines, "switch" and "Select Case" statements, in 2 locations, one for ASP and one for Javascript.
Repeating, I need some javascript syntax to call from inside the style=" attribute so that the pair color:value is really a color:function. I've tried a lot of ways without any errors but no color actually comes back in javascript. The result should be ... style="color: #FF0000; ... "or some other color"
Anybody?