Page 1 of 1
Getting error using "else if" in script
Posted: Wed Apr 08, 2009 2:42 am
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>
Use of javascript in IVR code
Posted: Wed Apr 08, 2009 9:02 am
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
script tag giving error by validator
Posted: Wed Apr 08, 2009 11:44 am
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
&& is not validated by plumvoice validator
Posted: Wed Apr 08, 2009 11:50 am
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>
">" illegal character in IVR application
Posted: Wed Apr 08, 2009 5:07 pm
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