I was just curious if there was an effective way to call a javascript function from within a PHP code block directly?
The following is what I would like to achieve;
<script language="JavaScript" type="text/javascript">
function setStyleYPos(elementRule, offset)
{
var yVal = document.styleSheets[0].rules[elementRule].style.top.substring(0, document.styleSheets[0].rules[elementRule].style.top.length - 2);
var newYVal = yVal - offset;
return "position:absolute;left:10px;top:" + newYVal + "px;";
}
</script>
<?php
print "<div style=";
// ?? Code to call javascript function goes here ??
print ">\r\n";
?>
As you may be able to see, I would like to derive a manipulated string extract from a stylesheet. As of right now, javascript is the only way I know how to do this. Then I would like that string to fill in the needed text to complete my <div> tag's style property. I guess you could say that I am trying to write code dynamically.
I'm not even sure that this approach can even be achieved in any way, but am open to any and all suggestions.
Thanks😕