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

Javascript returns string but not boolean!

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

Post Reply
soso
Posts: 62
Joined: Tue Apr 22, 2008 8:11 am

Javascript returns string but not boolean!

Post by soso »

Hi,

I try to use this code:

Code: Select all

<data name="auth" src="Get.aspx" namelist="ID phone" maxage="0"/>
                    <script>
bip = auth.documentElement.getElementsByTagName("bip").item(0).firstChild.data;
</script>

...

<field name="msg" cond="bip==false">
...
</field>
The value of "bip" element is true or false only.

But, when I execute the code, the value is always set to false, because the line script return a string, and not boolean value.

How do I use the script to return a boolean value?

Thanks by advance.

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

IVR code example for returning boolean value

Post by support »

Hi,

We're not sure what's happening in your Get.aspx script, but we've provided an IVR code example of how you can return a boolean value (0 or 1) using the IVR tag, <data>:

data.php:

Code: Select all

<?php
header("Content-type: text/xml");
echo("<?xml version=\"1.0\"?>\n");
$random1 = 0;
$random2 = 1;
?>

<booleans>
<boolean><?php echo($random1);?></boolean>
<boolean><?php echo($random2);?></boolean>
</booleans>
datavalueboolean.php:

Code: Select all

<?php
header("Content-type: text/xml");
echo("<?xml version=\"1.0\"?>\n");
?>
<vxml version="2.1">
  <form>
    <data name="thedata" src="data.php"/>

<script>
bip = thedata.documentElement.childNodes.item(0).firstChild.toString();
</script> 

      <block>
        The value is <value expr=
        "thedata.documentElement.childNodes.item(0).firstChild.toString()"/>.
      </block>
  </form>
</vxml>
Hope this IVR code helps.

Regards,
Plum Support

Post Reply