Page 1 of 1

Get the currently selected color in the Text Input

PostPosted: Mon Jun 08, 2015 12:03 am
by UltraVox
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

Re: Get the currently selected color in the Text Input

PostPosted: Mon Jun 08, 2015 12:27 am
by UltraVox
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.

Re: Get the currently selected color in the Text Input

PostPosted: Mon Jun 08, 2015 5:42 am
by Gaev
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.

Re: Get the currently selected color in the Text Input

PostPosted: Mon Jun 08, 2015 6:07 am
by UltraVox
Gaev,

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

Thx !