loading

HTA application help

Hello fellow friends,
I have an HTA (HTML application) and im trying to create a button to change the "img src". Im attemping this by using a variable, but it doesnt work heres my code so far:

<SCRIPT LANGUAGE="VBScript">
Sub Window_Onload
a="msgbox.jpg"
End Sub

Sub RunScript
a="test.jpg"
End Sub
</SCRIPT>


 <body>
<IMG SRC=a>
<input id=runbutton class="button" type="button" value="Run Button" name="run_button" onClick="RunScript">
</body>


Thanks in advance,
-animan


g-one6 years ago
The HTML text in an HTA file doesn't know any variables. Variables are only valid for the vbscript (inside of the script tags). Use a reference to the img-object. Assign an ID ...

<html>
  <head>
    <title>test</title>
    <HTA:APPLICATION
      ID="test"
      APPLICATIONNAME="test"
      SINGLEINSTANCE="yes"
      WINDOWSTATE="maximize"
    >
  </head>
  <script Language="VBScript">
    Sub Window_Onload
      Pic.src = "msgbox.jpg"
    End Sub

    Sub RunScript
      Pic.src = "test.jpg"
    End Sub
  </script>
  <body>
    <img ID="Pic">
    <input id=runbutton class="button" type="button" value="Run Button" name="run_button" onClick="RunScript">
  </body>
</html>
animan1 (author)  g-one6 years ago
Humm, I get what your saying, i never thought that i could aded an ID to the pic thanks! :)