• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Using Java script in CP6 vs. CP7

Contributor ,
Apr 12, 2014 Apr 12, 2014

Copy link to clipboard

Copied

Hi,

I have been taking Jim's class in javascript for CP7 - it's great! However, I have a client that needs to stay in CP6. I would love to use some of the same js that I got from Jim's class (which works great in my cp7) in cp6, but it is not working. Is there a different way we need to do js in cp6 vs. cp7? I am using the javascript by attaching it to a button and putting the js code in the script window. I'm new to js, so am still feeling my way around.

Thanks everyone - this forum is always so helpful!!

  Lori

TOPICS
Advanced

Views

482

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Apr 12, 2014 Apr 12, 2014

Copy link to clipboard

Copied

Hi Lori,

Can you post the script you are trying to use?

Thx,

Jim Leichliter

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Apr 12, 2014 Apr 12, 2014

Copy link to clipboard

Copied

It's one of yours from the video class. I'm starting with yours and then will make my necessary mods, but wanted to begin with something that works. It works like a charm on cp7, but not cp6

var onButtonClick = function(){

 

          var studentFirstName = getCpVariable('vFirstName');

          var studentLastName = getCpVariable('vLastName');

 

          if(studentFirstName != '' && studentLastName != ''){

                    setCpVarible('vMessage', 'Thank You ' + studentFirstName + '!');

                    setCpVarible('cpCmndResume', 1);

                    setCpVarible('cpCmndShowPlaybar', 0);

          } else {

                    setCpVarible('vMessage', 'Please fill out all required fields.');

          }

};

var setCpVarible = function(cpVariableName, valueToSet){

          var objCp = document.getElementById('Captivate');

          objCp.cpEISetValue('m_VarHandle.' + cpVariableName, valueToSet);

}

var getCpVariable = function(cpVariableName){

          var objCp = document.getElementById('Captivate');

          return objCp.cpEIGetValue('m_VarHandle.' + cpVariableName);

}

onButtonClick();

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Apr 12, 2014 Apr 12, 2014

Copy link to clipboard

Copied

LATEST

Looks like the code was missing two semicolons:

var onButtonClick = function(){

          var studentFirstName = getCpVariable('vFirstName');

          var studentLastName = getCpVariable('vLastName');

          if(studentFirstName != '' && studentLastName != ''){

                    setCpVarible('vMessage', 'Thank You ' + studentFirstName + '!');

                    setCpVarible('cpCmndResume', 1);

                    setCpVarible('cpCmndShowPlaybar', 0);

          } else {

                    setCpVarible('vMessage', 'Please fill out all required fields.');

          }

};

var setCpVarible = function(cpVariableName, valueToSet){

          var objCp = document.getElementById('Captivate');

          objCp.cpEISetValue('m_VarHandle.' + cpVariableName, valueToSet);

};

var getCpVariable = function(cpVariableName){

          var objCp = document.getElementById('Captivate');

          return objCp.cpEIGetValue('m_VarHandle.' + cpVariableName);

};

onButtonClick();

Give that a shot.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Help resources