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

Subit values to php page on key press not based length

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

Post Reply
kishore.inline
Posts: 19
Joined: Mon Jun 21, 2010 4:00 am

Subit values to php page on key press not based length

Post by kishore.inline »

Hi

As per my programming logic I want to submit all the key pressed 'customerid' numer based on # key pad not based on lenght of customerid.

<field name="customerid" type="digits?length=4">
<prompt>
You have selected for Clock In.
</prompt>
<prompt>
Enter Client ID and press Hash to Submit.
</prompt>
<filled>
You entered <value expr="customerid"/>.
<prompt>
Please wait while we process your information.
</prompt>
</filled>
<noinput>
Sorry, No Input received.
<reprompt/>
</noinput>
<nomatch>
Sorry, Invalid Client ID.
<reprompt/>
</nomatch>
</field>

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

Re: Subit values to php page on key press not based length

Post by support »

Hi,

If you want to allow for input of any length, the only change to your code would be to remove the ?length= on your "type" attribute:

Code: Select all

<field name="customerid" type="digits">
<prompt>
You have selected for Clock In.
</prompt>
<prompt>
Enter Client ID and press Hash to Submit.
</prompt>
<filled>
You entered <value expr="customerid"/>.
<prompt>
Please wait while we process your information.
</prompt>
</filled>
<noinput>
Sorry, No Input received.
<reprompt/>
</noinput>
<nomatch>
Sorry, Invalid Client ID.
<reprompt/>
</nomatch>
</field>
Regards,
Plum Support

kishore.inline
Posts: 19
Joined: Mon Jun 21, 2010 4:00 am

Re: Subit values to php page on key press not based length

Post by kishore.inline »

Hi

I want my values to be posted to PHP page or inputs to be validated on Key press of # symbol.

can you help on this.

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

Re: Subit values to php page on key press not based length

Post by support »

Hi,

If you want to write your application such that a value will only be submitted if the user presses the "#" key, then you want to use the <if> conditional. The following example uses your code and an <if> conditional to ensure that data is only submitted if the user presses the "#" key:

clockin.php

Code: Select all

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



<vxml version="2.0">
<form id="clockin">

<field name="customerid" type="digits?length=4">




<grammar root="ROOT" type="application/srgs+xml" mode="dtmf">
      <rule id="ROOT" scope="public">
        <one-of>
            <item repeat="0-255">
              <ruleref uri="#digit"/>
            </item>
          <item> "#" </item>
        </one-of>
      </rule>

      <rule id="digit" scope="public">
        <one-of>
          <item> 0 </item>
          <item> 1 </item>
          <item> 2 </item>
          <item> 3 </item>
          <item> 4 </item>
          <item> 5 </item>
          <item> 6 </item>
          <item> 7 </item>
          <item> 8 </item>
          <item> 9 </item>
          <item> "#" </item>
        </one-of>
      </rule>
    </grammar>




<prompt>
You have selected for Clock In.
Enter Client ID and press Hash to Submit.
</prompt>

<filled>
<if cond="customerid.indexOf('#') != -1">
  <assign name="customerid" expr="customerid.toString().replace(/#/,'')"/>
        <prompt>
          You entered <value expr="customerid"/>. Please wait while we process your information.
        </prompt>
      <else/>
        <prompt>
          You entered <value expr="customerid"/>. You must press hash to submit your client ID.
        </prompt>
	<clear namelist="sendid customerid clockin"/>
      </if> 
</filled>

<noinput>
Sorry, No Input received.
<reprompt/>
</noinput>
<nomatch>
Sorry, Invalid Client ID.
<reprompt/>
</nomatch>
</field>

<subdialog name="sendid" namelist="customerid" src="customerid.php">
<filled>
<if cond="sendid.confirmation=='verified'">
  <prompt>
    Your customer ID was verified.
  </prompt>
  <goto next="#caretaker"/>
<else/>
  <prompt>
    Your customer ID was not verified.
  </prompt>
  <clear namelist="sendid customerid clockin"/>
</if>
</filled>
</subdialog>
</form>

<form id="caretaker">

<field name="caretakerid" type="digits?length=6">
<prompt>
Enter CareTaker ID and Password. Enter CareTakerID followed by Star then Password. And press Hash to Submit.
</prompt>
<filled>
You entered <value expr="caretakerid"/>.
<prompt>
Please wait while we process your information.
</prompt>
<submit namelist="caretakerid" next="http://voicexcall.99k.org/TestVXML/CareTakerID.php"/>
</filled>
<noinput>
Sorry, No Input received.
<reprompt/>
</noinput>
<nomatch>
Sorry, Invalid CareTaker ID.
<reprompt/>
</nomatch>
</field>
<block>
Please hold for clockin.
</block>

</form>
</vxml>


customerid.php

Code: Select all

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

$customerid = $_GET[customerid];
$confirmation = "verified"; 
?>

<vxml version="2.0">
<form>
<block>
<var name="confirmation" expr="'<?php echo($confirmation)?>'"/>
<prompt>
Your Customer ID is <?php echo($customerid)?>.
</prompt>
<return namelist="confirmation"/>
</block>
</form>
</vxml>
Hope this helps.

Regards,
Plum Support

kishore.inline
Posts: 19
Joined: Mon Jun 21, 2010 4:00 am

Re: Subit values to php page on key press not based length

Post by kishore.inline »

Thanks for your support.

I have last and final question.

I have pressed the key as shown 232323*1234#

I have entered my userid and password dividing by star. Now my program should submit values based on # and should prompt the values that are given before the *.

How can I divide the given input based on * in voice xml code.

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

Re: Subit values to php page on key press not based length

Post by support »

Hi,

One way you could divide the input based on "*" in your vxml code would be to use the ECMAScript 'split' function, and split the input based on the "*" character. You could then assign each piece of the split input to a separate variable. Here's an example:

clockin.php

Code: Select all

<filled>
<if cond="caretakerid.indexOf('#') != -1">
  <if cond="caretakerid.indexOf('*') != -1">
	<assign name="id_pass" expr="caretakerid.toString().split('*')"/>
	<assign name="care_id" expr="id_pass[0]"/>
	<assign name="care_pass" expr="id_pass[1].toString().replace(/#/,'')"/>
        <prompt>
          Your CareTaker ID is <value expr="care_id"/>.
	  Your password is <value expr="care_pass"/>.
	  Please wait while we process your information.
        </prompt>
      <else/>
        <prompt>
          You entered <value expr="caretakerid"/>. You must enter your CareTaker ID followed by star then password.
        </prompt>
	<clear namelist="caretakerid care_id care_pass id_pass caretaker"/>
      </if>
  <else />
  <prompt>
  You entered <value expr="caretakerid"/>. You did not press hash, no data was sent.
  </prompt>
  <clear namelist="caretakerid caretaker"/>
</if>
</filled>
Hope this helps.

Regards,
Plum Support

Post Reply