620Views4Replies

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

Comments

The forums are retiring in 2021 and are now closed for new topics and comments.
0
orksecurity
orksecurity

Best Answer 10 years ago

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.)

0
animan1
animan1

Answer 10 years ago

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

0
g-one
g-one

10 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
      run_button2.Disabled=true
    else
      run_button2.Disabled=false   
    end if
    end sub

  </script>


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

0
animan1
animan1

Answer 10 years ago

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