Author Topic: JScript input box  (Read 4825 times)

thais

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
JScript input box
« on: January 10, 2011, 06:24:42 am »
Hello,

I want to write a Project Browser script in JScript and therefore I need inputs from the user.
How is it possible to write a input dialog box?

thanks!!

mrf

  • EA User
  • **
  • Posts: 311
  • Karma: +0/-0
    • View Profile
Re: JScript input box
« Reply #1 on: January 10, 2011, 08:55:18 am »
Unfortunately JScript has no intrinsic input box. You can use this trick though:

Code: [Select]
function InputBox( promptText /* : String */, title /* : String */, defaultText /* : String */ ) /* : String */
{
      // JScript has no intrinsic InputBox method, therefore we have to steal VBs
      var vbe = new ActiveXObject("ScriptControl");
      vbe.Language = "VBScript";
      
      return vbe.eval( "InputBox(\"" + promptText + "\",\"" + title + "\",\"" + defaultText + "\")");
}

Which creates a temporary VBScript engine, calls InputBox and returns the result to your JScript.
Best Regards,

Michael

[email protected]
"It is more complicated than you think." - RFC 1925, Section 2.8