Note that there are some explanatory texts on larger screens.

plurals
  1. POcalling javascript image opacity function from php echo
    text
    copied!<p>I've made it so that when you hover the cursor over the image button it starts fading and when you move the cursor out, it goes back to original opacity. The problem is that when I add php tags around the content in the body and echo the table, it no longer works. Thanks for advance for the help.</p> <p>Here's the code:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script type="text/javascript"&gt; function SetOpacity(elem, opacityAsInt) { var opacityAsDecimal = opacityAsInt; if (opacityAsInt &gt; 100) opacityAsInt = opacityAsDecimal = 100; else if (opacityAsInt &lt; 0) opacityAsInt = opacityAsDecimal = 0; opacityAsDecimal /= 100; if (opacityAsInt &lt; 1) opacityAsInt = 1; // IE7 bug, text smoothing cuts out if 0 elem.style.opacity = opacityAsDecimal; elem.style.filter = "alpha(opacity=" + opacityAsInt + ")"; } function FadeOpacity(elemId, fromOpacity, toOpacity, time, fps) { var steps = Math.ceil(fps * (time / 1000)); var delta = (toOpacity - fromOpacity) / steps; FadeOpacityStep(elemId, 0, steps, fromOpacity, delta, (time / steps)); } function FadeOpacityStep(elemId, stepNum, steps, fromOpacity, delta, timePerStep) { SetOpacity(document.getElementById(elemId), Math.round(parseInt(fromOpacity) + (delta * stepNum))); if (stepNum &lt; steps) setTimeout("FadeOpacityStep('" + elemId + "', " + (stepNum+1) + ", " + steps + ", " + fromOpacity + ", " + delta + ", " + timePerStep + ");", timePerStep); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;?php echo" &lt;form action='opacity.php' method='post'&gt; &lt;input type='image' name='blue' id='ImgAkxl2' value='blue' src='streetfighter.jpg' onmouseover='FadeOpacity('ImgAkxl2', 100, 70, 250 , 24)' onmouseout ='FadeOpacity('ImgAkxl2', 70, 100, 250 , 24)' /&gt; &lt;/form&gt; "; ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload