Source language: Translate to:

Get the currently selected color in the Text Input

Questions and information about using VBScript and JavaScript in NeoBook functions

Moderator: Neosoft Support

Get the currently selected color in the Text Input

Postby UltraVox » Mon Jun 08, 2015 12:03 am

Hi all,

I have an HTML page that is displayed in a WebBrowser, and contains a JavaScript for DialogColor. I would like to retrieve the HTML color by pressing a button that is inside my NB app. I've prepared a RAR file with the HTML file and the script (jscolor.js).

Download link (14 Kilo) : http://we.tl/Gh26omhB7U

I do not know how to get the currently selected color in the Text Input by pressing a NB button. A script (nbSetVar) has been integrated into the HTML page, but I do not know what command I have to put in the NeoBook button to retrieve the color.

Code: Select all
  <script>
   
   function getColor() {
     window.external.nbSetVar('[SkyBoxBGColor]', document.getElementById('color').value);
   }
  </script>


And, I feel that this script does not give me the color of the Text Entry, rather than line 7 of the HTML file.

Code: Select all
<input class="color" value="1CC2FF">


Any help will be welcome...

Thank you to all.
UltraVox
UltraVox
 
Posts: 419
Joined: Sat Jul 28, 2007 11:14 am
Location: France

Re: Get the currently selected color in the Text Input

Postby UltraVox » Mon Jun 08, 2015 12:27 am

Finally, the visual result is :

Image

The "OK" button is a NeoBook button, with which I would find the color displayed in the JavaScript Text Entry.
UltraVox
 
Posts: 419
Joined: Sat Jul 28, 2007 11:14 am
Location: France

Re: Get the currently selected color in the Text Input

Postby Gaev » Mon Jun 08, 2015 5:42 am

UltraVox:

1) Give a name to the input element ...
Code: Select all
   <input name="colorValue" class="color" value="1CC2FF">


2) For the click event of your NeoBook Button ...
Code: Select all
BrowserGetElement "WebBrowser1" "colorValue" "[colorValueNB]"
AlertBox "colorValueNB" "[colorValueNB]"


3) You do not need the getColor() function any more ... but if you were to use it elsewhere, note that when using getElementById(), you need to specify the id (same as name) i.e. colorValue ... color is the class of the element ...
Code: Select all
function getColor() {
     //window.external.nbSetVar('[SkyBoxBGColor]', document.getElementById('colorValue').value);
}



You might also look at this sample that I built years ago ... http://www.scriptedlogic.com/zzold/neoFREE1.htm ... to get ideas about capturing color values in javascript.
User avatar
Gaev
 
Posts: 3728
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: Get the currently selected color in the Text Input

Postby UltraVox » Mon Jun 08, 2015 6:07 am

Gaev,

That's great, thank you!
It works very well and it helps a lot.

Thx !
UltraVox
 
Posts: 419
Joined: Sat Jul 28, 2007 11:14 am
Location: France


Return to NeoBook Functions - VBScript & JavaScript

Who is online

Users browsing this forum: No registered users and 1 guest