hi dear experts...i dont know if im in the right forum but...if not please kindly move this thread..
my problem is that how to change value like this one:
-
<script language="JavaScript" type="text/javascript">
-
<!--
-
function css_style(css_choice) {
-
-
document.getElementById("css_style").innerHTML="css_styles/style"+css_choice+".css";
-
-
}
-
-->
-
</script>
-
[HTML]
<link href="<div id=css_style></div>" rel="stylesheet" type="text/css">
[/HTML]
I know this won't work...but i've done this if without that link tag...i can change the value of the div tag ... but what if i would like to place a value inside link tag particularly in the href value? just like the case above...
please help...TIA
try this:
assign your link tag an id.
<link id="YourLinkID" href="" rel="stylesheet" type="text/css">
then in your function:
<script language="JavaScript" type="text/javascript">
<!--
function css_style(css_choice) {
document.getElementById("YourLinkID").setAttribute ("href", "css_styles/style"+css_choice+".css");
}
-->
</script>
but a link is calling the stylesheet by using the URL in href at the time of LOADING, not after the page loaded, so even if you could change the URL in the href on the fly, there is no point to do so, because after you change href's value, the style used by the page does not change.
If you want to change the style on the fly, try thinking some other approaches.
BTW, this POST should be in JAVASCRIPT/AJAX forum, you may get more reply I think.