I hope this is just a syntax issue, but I can call a function when a page is served up like this:
which called from my element "<a" within the style attribute like this
and the color is set to #FF0000 or something else.
But I can't find a similar way to call a javascript function like this
from inside the
I want to change the font depending on the page, but use the same function for events.
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?
Code:
<% Function FFcolor(x) Select case x case 1: FFcolor = "#FF0000" case 2: FFcolor = "something else" etc. End Function %>
Code:
<a ... style="color: <%=FFcolor(x)%>; ... >
But I can't find a similar way to call a javascript function like this
Code:
<script type="text/javascript"> function FFcolor(x) { switch (x) { case 1: return "#FF0000"; case 2: return "something else"; etc. } } </script>
Code:
<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?
Comment