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
Copy link to clipboard
Copied
Hi Lori,
Can you post the script you are trying to use?
Thx,
Jim Leichliter
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();
Copy link to clipboard
Copied
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.