Javascript on Submit button - thisName.value statement help

I am still learning javascript and have been trying for some time to figure out where / what is missing in the following. This is code attached to a password submit button that Mark Hunte posted and I have been trying to modify (with a lot of his gracious time and assistance).

My challenge is I can not figure out the last few lines of code and how/what is being processed. I need to add a statement that will take any incorrect password entry for current scene “Starlight Question” (including someone who may just click the submit button without entering any password), and send it to scene “Starlight Denied”.
Right now it goes to “Promo”.

And the same for current scene “Mission Restart”. It should go to scene “Mission Command” on incorrect password or submit button. However, it also goes to “Promo”.

I managed (by dumb luck) to get it to go to “Mission Command” if there is no password entered and just the submit button is clicked, but that applies to both current scenes, which is not correct.

I do not understand the thisName value and proper command/syntax to get what I need. Any help would be appreciated.

  var  textAreas =  $('*[class^="HYPE_element\ textArea"]') ; 
 var theClassName = textAreas[0].className.split("HYPE_element ")[1];

var thisName = $("." + theClassName).children()[0];
var currentScenName = hypeDocument.currentSceneName();
//var password = thisName.value;

var thePassword;
var jumpScene;

if (currentScenName == ‘Promo’){
thePassword = "dg"
jumpScene = ‘Mission Command’

if (currentScenName == ‘Starlight Question’){
thePassword = "23"
jumpScene = ‘Starlight Correct’

if (currentScenName == ‘Mission Restart’){
thePassword = "20"
jumpScene = ‘Mission Command’

{pwd = password = thisName.value;

if (pwd !== "") {

if (password == thePassword){

hypeDocument.showSceneNamed(jumpScene, hypeDocument.kSceneTransitionCrossfade, 1.1)

thisName.value = “”;
hypeDocument.showSceneNamed(“Promo”, hypeDocument.kSceneTransitionInstant);
} else {
thisName.value = “”;
hypeDocument.showSceneNamed(“MIssion Command”, hypeDocument.kSceneTransitionInstant);

A lot to follow, I know. But hopefully it makes sense to those who understand :smile:
Your time and feedback is greatly appreciated.
Thank You.

Hi Derek,

Could you supply the hype document at all. This code although readable and understandable is a little difficult to place without the exact context.

This line of code to me doesn't make sense. It doesn't fit in with the rest of the code.

If you remove this line see what happens!


Hi Derek,

You should already have got my PM earlier asking about this…
Just realised you also asked it her.

If I under stand you right,

You just need to do something similar to how we go to the ‘Starlight Correct

We use a variable to set which scene to go to:

So you just need to do the same for denied scenes

  var jumpScene;
   var deniedScene;
  if (currentScenName == 'pswd1'){
  thePassword = "jawr"
  jumpScene = 'scene1'
  deniedScene = 'DeniedScene1'
  if (currentScenName == 'pswd2'){
  thePassword = "lawr"
  jumpScene = 'scene2'
   deniedScene = 'DeniedScene2'

Then change the two lines hypeDocument.showSceneNamed('Denied', hypeDocument.kSceneTransitionInstant);


hypeDocument.showSceneNamed(deniedScene, hypeDocument.kSceneTransitionInstant);


all the the

 var  textAreas =  $('*[class^="HYPE_element\ textArea"]') ; 
 var theClassName = textAreas[0].className.split("HYPE_element ")[1];
var thisName = $("." + theClassName).children()[0];

Is to get the value from the correct text view.

In my original keyboard I had more than one text Area.

This code is a hold over from that.

But you can replace in your code to one line:

var  thisTextArea  = document.getElementsByClassName('HYPE_element textAreaA')[0].childNodes[1];

And change any occurrences of thisName.value to :

 thisTextArea.value = "";

Which will make more sense to you.

Even though each password scene has a Text Area they both have the same class name. But only the current one should be found.


I just update that single line. I forgot to add .childNodes[1]; on the end which is the textArea

Hi @DBear,

I thought that that snippet is from a bit of code from Javascript Password - Switch or if/else? - #11 by ugomena,

But I just tried to look for it in the original post and could not find it as I have it.

So either I picked the idea of the double = vars up some where else or butchered it by accident. But it works !!! so go figure

{pwd = password = thisName.value;

Also you do not want to remove it. All the code works as I have given it.

What they want to do is adjust it. I have posted what they need to do above.. :smile:

but why the open curly brace and the close curly brace which is at the end i think ??

Yer it probably does not need the curly braces. But that was in the original and seems to have stuck…

So this all worked out fantastic.
Thanks DBear for your post as well.

I would just like to thank Mark for his very generous support and the amount of time he has spent helping me work through it all.

Thanks to all those great community minded genius’ out there :slight_smile: