Display all variables equal to "accept" or 'reject"

I am creating an app where users go through a series of about 30 screens. On each one there is a proposition that the user either accepts or rejects. I can set a global variable for each one and assign the value of either “accept” or “reject”. At the end there will be a screen that lists all the things the user accepted and another for the rejects. I can not figure out how to generate those two lists. Any pointers would be greatly appreciated.

This is just a quick example…

Choose Yes or No on each scene. on the last choice scene you will be able to go to view the lists.

In the head there are two array like objects. One for yes and one for no.

In the scene each yes button and no buttons are a elements of a symbol. ( saves on making multiple buttons for each scene).

The yes button has the class of yes and the no no.

The buttons each run a symbol time line and a javascript to add or replace a key value pair in the array like object.

The last scene button to go to lists. Runs the Javascript to get the lists and display it.

YesNo.hypetemplate.zip (75.2 KB)



2 Likes

Thanks Mark, that’s exactly what I need. I don’t think I could have figured it out on my own.

Hi Mark
I adapted your code and it works perfectly when I run it in Preview mode but when I upload it to the server (http://kozist.com/?p=295) I get the following errors when either the Accept (yes) or Reject (no) buttons are clicked (starts on the fifth screen):

[Log] Error in makeArrarys: TypeError: undefined is not an object (evaluating ‘window.NoListObjects[thisScene] = thisSelection’) (HYPE-466.thin.min.js, line 14)
[Log] Error in makeLists: TypeError: Requested keys of a value that is not an object. (HYPE-466.thin.min.js, line 14)

[Log] Error in makeArrarys: TypeError: undefined is not an object (evaluating ‘window.NoListObjects[thisScene] = thisSelection’) (HYPE-466.thin.min.js, line 14)
[Log] Error in makeLists: TypeError: Requested keys of a value that is not an object. (HYPE-466.thin.min.js, line 14)

At the end it should list the attributes (as in your original code). Works in Preview but not on the live site.

Do you have any thoughts on what might be causing the problem (other than my incompetence)?

Thanks

Hi Dave,

What browser are you using?

Also have you changed the code in any way? Are you using any other javascript or is your site a CMS? It could be something inside your live site that is conflicting with the code.

Try taking the var off the front of the variable declarations in “makeArrays” this will make them more accessible. This shouldn’t need to be done but it might in your case.

D

Hi DBear

Mostly Safari but I get the same results from Chrome Firefox and IE. The code was changed to add:
theYesBox.innerHTML = theYesString;
theYesBox2.innerHTML = theYesString;
theYesBox3.innerHTML = theYesString;
theNoBox.innerHTML = theNoString;
theNoBox2.innerHTML = theNoString;
theNoBox3.innerHTML = theNoString;

to address multiple layouts.

The Hype document is embedded in a Wordpress page (everything up to date, Avada theme). You are right that it’s a problem with Wordpress somewhere because if I go to the document as a stand alone http://kozist.com/wp-content/hype/Warrior1/Warrior1.html it works fine.

I tried taking the var off but it made no difference. I have also disabled plugins and changed themes with the same results.

In Firefox the error is “Error in makeArrarys: TypeError: window.YesListObjects is undefined”.

window.YesListObjects is declared in the head HTML in Hype.

I have seen postings about this happening with jquery but as far as I can tell this script does not call jquery.

Thank you for taking the time on this, it is very much appreciated.
Dave

Hi Dave,

I notice that on your main site where you have the Hype document inside a post, there are no variables for “window.YesListObjects” and “window.NoListObjects” defined. Have you included them in the Sites Head HTML?

Note the Javascript error that you’re getting is quite a common one. It basically means that it cannot find the object or variable.

D

1 Like

Hi DBear

You nailed it, the variable was declared in the head HTML of the Hype document but had to be declared in the head of the Wordpress document.

For anyone searching the forum for this problem here is how it was solved.

Install the “Per page add to head” plugin https://wordpress.org/plugins/per-page-add-to/

Edit the post or page that the Hype document is embedded in and look for the “Add to head” window under the editor.

Add your declaration. In this case it was:

That should solve the problem. This may be needed for all global variables, I’ll have to test to see.

Thank you DBear and MarkHunte for solving this problem. I definitely learned a lot.

Dave

1 Like

@DBear,

Thanks for looking at this, @dburdick sorry I was away this weekend.

Glad it is sorted.