We've Moved! Please visit our new and improved forum over at our new portal: https://portal.plumvoice.com/hc/en-us/community/topics

Getting error using "else if" in script

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

Post Reply
amitkhosla
Posts: 53
Joined: Sun Feb 15, 2009 11:42 pm
Contact:

Getting error using "else if" in script

Post by amitkhosla »

Hi

CAn you help me in correcting the script below. How to apply else if condition which check for both conditions to be true like else if(con1 && cond2)

does && is not supported?

<filled>
<script>
hours = parseInt(appTime.substr(0,2));
mins = parseInt(appTime.substr(2,4));
var ampm = "am";
if (hours > 12) {
ampm = "pm";
hours = hours - 12;
}
else if (hours == 12 and mins > 0) {
ampm = "pm";
}

formattedTime = hours + ":" + mins + " " + ampm;
</script>
<assign name="appointmentTime" expr="appTime.substr(0,2)+':'+appTime.substr(2,4)"/>
</filled>

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

Use of javascript in IVR code

Post by support »

Hi,

We recommend that you read up on using javascript to use with IVR code.

As for your question, "&&" is supported, as shown in this javascript example for the <script> tag:

Code: Select all

<script type="text/javascript">
var d = new Date()
var time = d.getHours()
if (time<10)
{
document.write("<b>Good morning</b>");
}
else if (time>10 && time<16)
{
document.write("<b>Good day</b>");
}
else
{
document.write("<b>Hello World!</b>");
}
</script>
Hope this helps.

Regards,
Plum Support
Last edited by support on Mon Jan 11, 2010 2:47 pm, edited 3 times in total.

amitkhosla
Posts: 53
Joined: Sun Feb 15, 2009 11:42 pm
Contact:

script tag giving error by validator

Post by amitkhosla »

I'm familiar with javascript. Actually when i use <script type="text/javascript"> and try to validate the code using the plumvoice validator it says "No declaration for attribute type of element script"

And even give the same error if i use && in else if () condition.

Please help me

amitkhosla
Posts: 53
Joined: Sun Feb 15, 2009 11:42 pm
Contact:

&& is not validated by plumvoice validator

Post by amitkhosla »

Hi

why is the below code not validated by validator. if i replace && by || then it get validated.

<?xml version="1.0"?>
<vxml version="2.0">
<form id="new_appointment_main_frm">
<property name="timeout" value="30s"/>
<script>
var hours = parseInt(appTime.substr(0,2));
var mins = parseInt(appTime.substr(2,4));
var ampm = "am";
if (hours>12) {
ampm = "pm";
hours = hours - 12;
}
else if (hours==12 && mins>0) {
ampm = "pm";
}
var formattedTime = hours + ":" + mins + " " + ampm;
</script>
</form>
</vxml>

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

">" illegal character in IVR application

Post by support »

Hi,

Have you tried changing the ">" character to ">" within your voicexml <script> tags of your IVR code? It is regarded as an illegal character in VXML.

Regards,
Plum Support

Post Reply