You need to sign in to do that
Don't have an account?
David Walshe
Question on Onclick Javascript - Getting error "Unexpected token ;"
Hi,
I am trying to a button using Javascript which uses a variable determined by whether the user has selected either standard or premium support.
However, I keep getting "Unexpected token ;". Any help is appreciated.
Here is the script I am using:
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/20.0/apex.js")}
var cost;
if ({!ISPICKVAL(Quote.S_W_Support_Level__c , 'Premium')}) {
cost = {!Quote.S_W_Premium_Maintenance__c};
} else {
cost = {!Quote.S_W_Standard_Maintenance__c};
}
I am trying to a button using Javascript which uses a variable determined by whether the user has selected either standard or premium support.
However, I keep getting "Unexpected token ;". Any help is appreciated.
Here is the script I am using:
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/20.0/apex.js")}
var cost;
if ({!ISPICKVAL(Quote.S_W_Support_Level__c , 'Premium')}) {
cost = {!Quote.S_W_Premium_Maintenance__c};
} else {
cost = {!Quote.S_W_Standard_Maintenance__c};
}
like
cost = '{!Quote.S_W_Premium_Maintenance__c}';
All Answers
cost = {!Quote.S_W_Premium_Maintenance__c};
cost = {!Quote.S_W_Standard_Maintenance__c};
It now returns the error "Unexpected token }".
If I use the following it works correctly when "Premium" is selected, however I get the unexpected token when Standard is selected.
if ({!ISPICKVAL(Quote.S_W_Support_Level__c , 'Premium')}) {
cost = {!TEXT(Quote.S_W_Premium_Maintenance__c)};
} else {
cost = '2345';
}
There appears to be a problem when using two different variables in the if-else statement.
like
cost = '{!Quote.S_W_Premium_Maintenance__c}';
Regards
David