JavaScript problem with if/else instructions

Hello!

I have a test page.  The goal is to hide the following custom button when you enter the page and allowing it, when the test has passed or failed for the last time.  Then if the user navigates on the same quiz page, the next button should already be displayed.  I'm doing it by assigning a value of 0 or 1 to a variable and triggering an if statement if the value withdraws.

When you enter the page I run the following code:

var slideRef = window.cpAPIInterface.getCurrentSlideIndex ();                        Gets the current page number

CP. Hide ('next_button_KBQ_' + slideRef);                                                        hide the next button

var isTaken = window.cpAPIInterface.getVariableValue ("L4_KBQ1_taken");   assigns a variable value (variable defined in Captivate with an initial value of 0)

Console.log ("isTaken value is" + isTaken);

If (isTaken = 1) {//if this quiz page has been adopted, following button

CP. Show ('next_button_KBQ_' + slideRef);

Console.log ("Enabling Next Button");

} else if (isTaken = 0) {}

CP. Hide ('next_button_KBQ_' + slideRef);                                                    This should not be necessary, but it's here for testing purposes

Console.log ("next button should be disabled");

}

success and a part of the last attempt of the quiz I run the following code:

var slideRef = window.cpAPIInterface.getCurrentSlideIndex ();

window.cpAPIInterface.setVariableValue ("L4_KBQ1_taken", 1);                   assign the variable with a value of 1

CP. Show ('next_button_KBQ_' + slideRef);

When I run the course, I get the following console result:

isTaken value is 0

Next button activation

If the button is displayed from the start.  If I take the test and return to the page, the bed console

isTaken value is 1

Next button activation

Then the variable is changing, Captivate reads the value of the variable very well, but it ignores the conditions and display the button in any case from the beginning.  What happens here?

Thank you!

You need to use is during the comparison, not =. In addition, you need another if, just another because there are only 2 options.

If ( == 1 isTaken) {//if this quiz page has been adopted, following button

CP. Show ('next_button_KBQ_' + slideRef);

Console.log ("Enabling Next Button");

} else {}

CP. Hide ('next_button_KBQ_' + slideRef);                                                    This should not be necessary, but it's here for testing purposes

Console.log ("next button should be disabled");

}

Tags: Adobe Captivate

Similar Questions

  • Problem with if/else instructions embedded in the options of the menu drop-down

    Hello

    I have a problem, try to add conditions together.

    I have a form that has so many drop-down menus with the same options of 1 to 5. However, a user does not choose the same option in any downs drop different two or more. for example if the drop-down list 1 has an option of '1' then drop-down menu 2 must have a different option, dropdown 3 must have a different option etc.

    I can't seem to get my script to run successfully. I need to combine statements.

    A person can be of any help please?

    My script for the first drop-down is:

    if (this.rawValue = Drop2.rawValue)
    { 
    
    xfa.host.messageBox("You cannot have duplicate positions for different financial threats/risks/hazards. Please choose another position!");
    
    
    }else if (this.rawValue = Drop3.rawValue){ 
    
    xfa.host.messageBox("You cannot have duplicate positions for different financial threats/risks/hazards. Please choose another position!");
    }else if (this.rawValue = Drop4.rawValue){ 
    
    xfa.host.messageBox("You cannot have duplicate positions for different financial threats/risks/hazards. Please choose another position!");
    }else if (this.rawValue = Drop5.rawValue){ 
    
    xfa.host.messageBox("You cannot have duplicate positions for different financial threats/risks/hazards. Please choose another position!");
    
    } 
    
    else if (this.rawValue == 1 && this.rawValue != Drop2.rawValue && this.rawValue != Drop3.rawValue && this.rawValue != Drop4.rawValue && this.rawValue != Drop5.rawValue){
    FINANCIAL_1_1.rawValue = FINANCIAL_1.rawValue;
    } else if (this.rawValue == 2){
    FINANCIAL_1_2.rawValue = FINANCIAL_1.rawValue;
    } else if (this.rawValue == 3){
    FINANCIAL_1_3.rawValue = FINANCIAL_1.rawValue;
    }
    
    

    It doesn't seem to work.

    Send the form to [email protected] and I can take a look.

    Steve

  • problem with if/else with liquid trying to fill out a form in advance

    I'm trying to automatically fill out parameters with a custom using liquid - field you see something wrong with the statement ' if/else '? AutoFill works OK if it is not empty but is unable to do the part "else" (replace with "New South Wales" If empty) - thanks in advance!

    Billing booking status < label for = "CAT_Custom_20031893_187341" > < / label >

    < select name = "CAT_Custom_20031893_187341" id = "CAT_Custom_20031893_187341" class = 'required cat_dropdown' >

    "< option value =" ">--please select--< / option >".

    {% If CAT_Custom_20031893_187341! = "" %}}

    < option value = '{module_customerfield, 187341, 20031893}' selected = "selected" > {module_customerfield, 187341, 20031893} < / option >

    < option value = "New South Wales" > New South Wales < / option >

    {%-%}

    < option value = "{module_customerfield, 187341, 20031893}" > {module_customerfield, 187341, 20031893} < /op ing >

    < option value = "New South Wales" selected = "selected" > New South Wales < / option >

    {endif %}

    < option value = "Queensland" > Queensland < / option >

    < option value = "South Australia" > South Australia < / option >

    < option value = "Tasmania" > Tasmania < / option >

    < option value = "Victoria" > Victoria < / option >

    < option value = "Western Australia" > Western Australia < / option >

    < / select >

    < script type = "text/javascript" >

    document.getElementById('CAT_Custom_20031893_187341').value = "{module_customerfield, 187341, 20031893};

    < /script >

    Not all variables 'empty' corresponding to the empty string.

    Try something like {% if CAT_Custom_20031893_187341 and CAT_Custom_20031893_187341 != "" -%} .

  • Problem with if/else

    I'm working on a script that will import data from a CSV file and use it to set up a host of newly built.  Where I'm going to have a difficult time is that in the CSV file I Datacenter and Cluster like columns and I need to set up a foreach interviewing then vCenter to see if there is a data center by the name specified in the CSV file, and if yes, then interrogate the datacenter to see if a cluster by the name listed in the CSV file file exists and then finally add the host to the cluster and repeat to the line next to the file.  If he asks vCenter and does not have a datacenter by the name specified in the CSV file, it then creates the datacenter and the cluster, then add is the host.  I hope this makes sense.  Thanks for the help to come is to work this issue.

    A slight variation which makes use of the pipeline, as appropriate, and who reads the input file only once.

    Import-Csv "C:\input.csv" | %{
        $dc = Get-Datacenter -Name $_.Datacenter -ErrorAction SilentlyContinue    if(!$dc){
            New-Datacenter -Name $_.Datacenter -Location (Get-Folder Datacenters) | `        New-Cluster -Name $_.Cluster | `
            Add-VMHost -Name $_.Host -User  -Password 
        }
        else{
            $clus = Get-Cluster -Name $_.Cluster -Location $dc -ErrorAction SilentlyContinue        if(!$clus){
                New-Cluster -Name $_.Cluster -Location $dc | `
                Add-VMHost -Name $_.Host -Location $clus -User  -Password 
            }
            else{
                Add-VMHost -Name $_.Host -Location $clus -User  -Password 
            }
        }
    }
    

    Notice that to create the data center, when it is not present, you must specify the location.

    I used the shadow of data originally from the vCenter centers folder.

  • [CS3] [javascript] Problem with the use of textWrapOffset in textWrapPreferences

    Hello world

    I'm having some trouble with the help of textWrapOffset.

    Alert (mySelection.textWrapPreferences.textWrapOffset);
    mySelection.textWrapPreferences.textWrapOffset [0] = 20;
    Alert (mySelection.textWrapPreferences.textWrapOffset);

    In the code above, the first la premiere alerte alert outputs four film text offsets existing (for example [3, 0, 0, 0]). But after trying to change the top of the textWrapOffset page in the second line of code, the last alert still exits the film ancient text offset and does not show the change. It's as if the textWrapOffset is read-only. Or is there something I'm missing?

    Note that before you run the script, the object selected in InDesign is a simple "Rectangle".

    I hope someone can help!

    Paul

    The value should be set as an array.

             myTextWrapOffset =
    mySelection.textWrapPreferences.textWrapOffset;
             myTextWrapOffset[0] = 20;
             mySelection.textWrapPreferences.textWrapOffset =
    myTextWrapOffset;
    

    Substances

    http://www.in-tools.com

  • Connected HP OfficeJet Pro 8600 Plus status reads "problem with printer."

    I could just ePrint on an OfficeJet Pro 8600 Plus replacement and them have not used for printing yet. I was in the devices page to manage the settings and change an address for one of my devices. The newly added column 8600 State reads 'Online', but also 'problem with printer '. Instructions I was referring to the display panel of the unit for Outlook2003 on the given problem. A check of the display surface showed no information, just a typical home screen. I checked through the display print and found no problems-all functionality is enabled and fully functioning. I checked then the functions of printer in the window 'Printers and devices' of all computers (all running Windows 7 Professional) on the office network. The 8600 are active and full functionality works correctly between the printer and all the computers.

    I then close the printer 8600, left for several minutes, and then lit it back and reconnected. The State says 'Problem with printer' remains in the device window HP.

    I am at a loss as to what this supposed problem can be and don't know what should be a next step. Does anyone have any advice or information that could help in this situation? It would be appreciated. Thanks in advance to those who could help

    HP support responded to my question by e-mail. I was told that the message 'Problem with the printer' is due to a bug in their system. Also said that as long as the status column indicates the printer is "Online" and everything else is fnctioning correctly, don't worry about this.

    I consider that a resolution of the post!

  • Want 700-327c graphic problem with Google Earth

    Lettering not appearing is not in some areas: Search button, tools > Options (no registration). Entry displays not to when you type in the search box.  View do not come out correctly.  Graphics card: Intel (r) Graphics HD 4600 worm: 10.18.10.3621(5/17/14). I tried to update by Intel, but the answer was that this card had been changed by the manufacturer of the computer, ask the update through HP.

    Have you tried UN/reinstall.

    Have not had problems with something else.

    Chop21, welcome to the forum.

    This isn't a hardware problem.  I suggest that you go to their support help page.  They are the experts on their program.

    Please click on the Thumbs up button '+' if I helped you and click on "Accept as Solution" If your problem is resolved.

  • Problems with HTTPS and javascript widgets

    My HTTP site works fine, but when I switch to HTTPS, I get the following error...

    MuseJSAssert: Error calling the function switch: TypeError: E.split is not a function

    I have even tried to create a simple page with nothing else than a javascript widget, and I still get the error when you use the HTTPS version.

    FYI - I upload my pages using the 'upload to the FTP host.

    Muse and HTTPS is not compatible?

    It is more likely a problem with your server as a problem of cross-site script because the HTTPS protocol uses a folder or a different domain and browser security mechanisms as long as the server itself remove access to the script so. If there is a specific secure folder on the server, import is your files, otherwise, you will need to set an option in the web interface to allow HTTPs and normal HTTP access to your folder.

    Mylenium

  • Problems with external javascript file

    For some reason, I can't get a text external/javascript [.js] file works correctly on my Web page. I went to Adobe Help Viewer and follow the instructions clearly. But it all comes to a cause I can't seem to see a little icon in fashion design javascript to connect my widget external javascript to support javascript on my page. Why is this? I have the visual aid invisible items checked as well. Here is an article of the code below.

    Rufus65 wrote:
    > I'm sorry, I went from one problem to another, the first problem with the
    > javascript shield was my main problem and the first and its fixed. now, it's a new
    > problem, but I think I can just cut this time around, I got the codes mutilated
    > of this site: http://www.widgetbox.com/#. it allows you to customize your own
    > widgets and I thought that it was legitimate, apparently is not. to solve my javascript
    > problem, basically I want to just a website that has downloadable widgets for me
    > to insert into my website using dreamweaver CS3. That is my main task, I was
    > trying to accomplish. I started 5 steps before this goal which was not brilliant
    > at all. So my main problem [outside my other topic post on my screwed upward
    [> header] is just to get legitimate widgets that are free and easy to use in
    > dreamweaver CS3, cause I don't have time to learn Javascript code or whatever it is
    > close to him.

    Depends on which widgets you want and what you need to make them specifically for you. Maybe start a new thread, listing widgets that you feel you need and what you want to do with them.

    You do not have available in the Insert bar Spry widgets, but they can or may not be able to accomplish some of the things you like to do, be specific about what you want to do on your end, and what you want the end result to be. Send examples if you have.

    Many widgets will require some, if not encoding extended, to get the best out of them. For example, widgets to http://ui.jquery.com/ can do something relatively well, but in Dreamweaver CS3, you need to enter the code to be able to set a lot of options.

    Where it's important, DWCS4 added a "web widgets" option that allows you to install widgets from the Exchange:
    http://www.Adobe.com/cfusion/exchange/index.cfm?s=5&from=1&o=desc&cat=290&l=-1&event=Produ ctHome & exc = 3

    But even once, they may need a little digging intot he code to get the best of them.

    HTH

    --
    Danilo Micen
    | http://blog.Extensioneering.com/
    | Extensioneer WebAssist
    | Adobe Community Expert

  • Download a file should implement an option to open the file or save it - for some reason any now just downloading it straight to the download folder. Why? Problem with Firefox or something else?

    Download a file would normally bring up an option to open the file with the appropriate program or save it - for some reason any now just downloading it straight to the download folder. Why? Problem with Firefox or something else? It is very frustrating - sometimes, you want the first opened file so it can be discarded or stored in a different location.

    Find the type of file in the Firefox -> Options -> Applications Panel, open its menu drop-down and select 'ask '. To reset all the actions of download, delete the mimeTypes.rdf file in your Firefox profile folder (or rename the mimeTypes.rdf X if you want to save as a backup). The file will be regenerated with all types of files, restore the default actions.

    For more information, see application Panel - set how Firefox handles different file types and change what Firefox does when you click on or download a file .

  • Anyone else having problems with registering for hotmail today?

    Hotmail

    Anyone else having problems with hotmail registration today.  I'm really p...d like I got problems for part of the day of yesterday too... not very reliable and very frustrating to say the least

    Hello DianneCarrington,

    The best place to ask your question of Windows Live is inside Windows Live help forums. Experts specialize in all things, Windows Live, and would be delighted to help you with your questions. Please choose a product below to be redirected to the appropriate community:

    Windows Live Mail

    Windows Live Hotmail

    Windows Live Messenger

    Looking for a different product to Windows Live? Visit the home page Windows Live Help for the complete list of Windows Live forums to www.windowslivehelp.com.

  • Is a message "cannot find server" a problem with Internet connectivity or something else?

    Original title: Net question?

    When I get a message "cannot find server", is this a problem with internet connectivity or something else?  MSN and explore will be not open.  Thank you.

    Hi Aziz,.

    The Cable Guy came and installed a new modem and the new thicker cable.  So far so good.  Thanks for your reply.

  • Laptop had a problem to "Solve a problem with PSIKey", solution from Windows & installed according to the instructions. How will I know that the problem is solved?

    has stopped working properly.

    An update is available that solves this problem.

    Downloaded Update site Web Protexis, Inc. and told to follow the steps in the installation wizard. The file downloaded and said he was setting up installation. Then after a few seconds, the box has disappeared and nothing else happened. How will I know if this problem has actually been resolved? My laptop has shown 6 problems with this unit from 30/07/11-08/12/11, where the unit has stopped working. Because I don't know what it is yet, I don't know really if the problem is solved or not. What should I do at this point? I have a SP2 7520-5185, running Vista Home Premium, Acer-Aspire. Thanks for any help you can give.

    Hello

    If you have installed a trial or paid a licensed version of Corel software products, you probably may notice a third unannounced software application makes its way into your computer too. The program is PSIService.exe by Protexis, which installs a Protexis V2 of Licensing Windows operating system service or Protexis licensing service.

    PSIService belongs to protect DRM (digital rights management) copy protection and license management software, which is intended to protect an application or software against piracy and illegal copying. Thus PSI service is normally installed by another program, such as Corel Paint Shop Pro Photo X 2, Corel Paint Shop Pro XI (X 1), Corel Paint Shop Pro X, that uses its service to collect information of license to repatriate much like spyware, protect copy and authenticate the user who is using an authentic version of the program.

    When you tried to download and install the program, if the box that says closed the dialog box when the download is complete has been verified, it will close the dialog box.

    I suggest that you restart the computer and check if you get an error message.

  • Is anyone else having problems with gMusic?

    My gMusic application worked fine, but now it doesn't work at all. Never. Does anyone else have this problem? I want to X 2 (which I LOVE) and Google game works fine on my phone, but the gMusic app will not work on the desire. He is used to, maybe up to a month or two ago. There is not a single song in my library that will play. I tried to uninstall and reinstall the application... no luck. I thought that maybe my files were corrupt, but as I said, it works very well on my phone, so I don't know what the deal is.

    I can't say for sure, but it could be a problem with the application itself however, I'd suggest a refresh on the system running if you don't have it already. Then reinstall the application.

    Refresh your PC without affecting your files

    If your PC does not perform as in the past, and you don't know why, you can refresh your PC without delete all of your personal files or change your settings.

     

  • Is anyone else having problems with Windows 8 when your typing and e-mail? For some reason, it comes out constantly to the tile screen while I type making me about starting more.

    Is anyone else having problems with Windows 8 when your typing and e-mail? For some reason, it comes out constantly to the tile screen while I type making me about starting more.

    Hi Chaz,

    I thank you for your message and gives us a chance to help you. I see that the Mail app closes while you are typing an email.

    Please answer these questions to get a better understanding of the issue.
    1 have changes made to your computer before this problem?
    2 shut down other applications while they are in use?
    3. do you get an error code?

    You can try these methods to check whether the problem is resolved.

    Method 1: Run the troubleshooter of app.

    http://download.Microsoft.com/download/F/2/4/F24D0C03-4181-4E5B-A23B-5C3A6B5974E3/apps.diagcab

    Open this link to launch the troubleshooter.

    Method 2: Update the application.

    Method 3: Reinstall the application.

    This link has the steps that you can follow to update and reinstall the application.

    http://Windows.Microsoft.com/en-us/Windows-8/what-troubleshoot-problems-app

    Feel free to use the forum for any other issue of Windows, you may have.

Maybe you are looking for