Author Options:

Constantly Test Variable in an HTML Application (HTA)? Answered

Hello I have a text area in an HTA form. I want to test if the area is empty, if so, disable a button using (run_button2.Disabled =True/False), if not enable the button. here is my <body> section

<body bgcolor
<textarea name="Text1" rows="8" cols="60"></textarea>
<input id=runbutton2 type="button" value="Copy Text to Clipboard" name="run_button2" onClick="Copy_Solution">

Script language is VBScript
my big problem is that i dont know how to call a sub to repeat maybe i should you Window_onload with a loop but i dont know i that would slow the program down any PLEASE HELP


Wouldn't it be just as easy to register a keystroke-event handler on that form field, and only check for empty or non-empty when the value actually changes? Much more efficient, leaves your machine free to spend its cycles on something more useful when you aren't actually typing....

(I don't use VBScript, so it's possible that it really can't do this. I'd be shocked, though; these days event-driven programming is standard for user interfaces.)

even thought you didnt give me code, i used my own knowledge to work it out with your METHOD. Thank you *Gives Best Answer*


7 years ago

Use a timer to call another sub.

  <script language="VBScript">

    sub Window_onLoad()
     iTimerID = window.setInterval("checkempty", 100, "VBScript")
    end sub
    sub checkempty()
    if document.all.Text1.value="" then
    end if
    end sub


checkempty() runs in an infinite loop once in 100 ms.

Thanks for your help but i used Orksecurity's method, whenever the text change i Enable/Disablle the button