Note that there are some explanatory texts on larger screens.

plurals
  1. POGet .aspx control ID in .js file
    primarykey
    data
    text
    <p><strong>Hello everyone,</strong></p> <h2><strong>(HEAD PART)</strong></h2> <pre><code>&lt;script type="text/javascript"&gt; function ChangeColor1(elementid) { document.getElementById(elementid).style.backgroundImage = "url('images/1.jpg')"; document.getElementById("&lt;%= img2.ClientID%&gt;").style.backgroundImage = "url('images/2.jpg')"; document.getElementById("&lt;%= img3.ClientID%&gt;").style.backgroundImage = "url'images/2.jpg')"; document.getElementById("&lt;%= img4.ClientID%&gt;").style.backgroundImage = "url('images/2.jpg')"; document.getElementById("&lt;%= imgchange.ClientID%&gt;").style.backgroundImage = "url('images/img1.JPG')"; } function ChangeColor2(elementid) { document.getElementById(elementid).style.backgroundImage = "url('images/1.jpg')"; document.getElementById("&lt;%= img1.ClientID%&gt;").style.backgroundImage = "url('images/2.jpg')"; document.getElementById("&lt;%= img3.ClientID%&gt;").style.backgroundImage = "url('images/2.jpg')"; document.getElementById("&lt;%= img4.ClientID%&gt;").style.backgroundImage = "url('images/2.jpg')"; document.getElementById("&lt;%= imgchange.ClientID%&gt;").style.backgroundImage = "url('images/img2.JPG')"; } function ChangeColor3(elementid) { document.getElementById(elementid).style.backgroundImage = "url('images/1.jpg')"; document.getElementById("&lt;%= img1.ClientID%&gt;").style.backgroundImage = "url('images/2.jpg')"; document.getElementById("&lt;%= img2.ClientID%&gt;").style.backgroundImage = "url('images/2.jpg')"; document.getElementById("&lt;%= img4.ClientID%&gt;").style.backgroundImage = "url('images/2.jpg')"; document.getElementById("&lt;%= imgchange.ClientID%&gt;").style.backgroundImage = "url('images/img3.JPG')"; } function ChangeColor4(elementid) { document.getElementById(elementid).style.backgroundImage = "url('images/1.jpg')"; document.getElementById("&lt;%= img2.ClientID%&gt;").style.backgroundImage = "url('images/2.jpg')"; document.getElementById("&lt;%= img3.ClientID%&gt;").style.backgroundImage = "url('images/2.jpg')"; document.getElementById("&lt;%= img1.ClientID%&gt;").style.backgroundImage = "url('images/2.jpg')"; document.getElementById("&lt;%= imgchange.ClientID%&gt;").style.backgroundImage = "url('images/img4.JPG')"; } &lt;/script&gt; </code></pre> <h2><strong>(BODY PART)</strong></h2> <pre><code>&lt;table&gt; &lt;tr&gt; &lt;td id="img1" runat="server" onmouseover="ChangeColor1(this.id)" style="background-image: url('images/2.jpg')"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td id="img2" runat="server" onmouseover="ChangeColor2(this.id)" style="background image: url('images/2.jpg')"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td id="img3" runat="server" onmouseover="ChangeColor3(this.id)" style="background-image: url('images/2.jpg')"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td id="img4" runat="server" onmouseover="ChangeColor4(this.id)" style="background-image: url('images/2.jpg')"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <hr> <p>This code is working fine in .ASPX page.</p> <p>But when I put this script code in .js file and call it in head part of .ASPX page, this .js file is not working well.</p> <p>ID=img2, ID=img3, ID=img4 of <strong>td</strong> is not passing in .js file.</p> <p>How can I pass this all ID in .js file???</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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