Survey & radio button example

Topics: Developer Forum
Feb 19, 2011 at 9:36 PM
Edited Feb 21, 2011 at 11:49 PM

Figured out a way to do radio buttons, which is the starting point for creating a survey application.

Check out my example at http://raround.com/avp/default.aspx

1. Click on the Session VFP/HTML table

2. Click on any person such as Antonio Baker

3. In the customer detail page whose partial HTML is below, the "client" textfield has a numeric value (1 to 4) which is the value of the character "client" field I added to customer.dbf.

4. Then there's a separate input area for the radio buttons called "clientval".   Using the IIF command shown, the radio buttons are set to display the current value of "client" in customer.dbf. 

5. Here is the HTML inserted into the detail.htm template for the radio buttons.

            </tr>
<!-- Client -- This table row holds the value of the Client field I added to the customer.dbf table -->
<tr>
<td>Client:</td>
<!--AVFP-> <td><input name="Client" size="5" value="<_%=osession.VALUE("Client")%_>"></td> -->
<td><input name="Client" size="5" value="3"></td>
</tr>
<!-- Clientval -- This table row holds the form radio buttons and an IIF command to
determine whether or not the radio button should be checked -->

            <tr>
<td>Client:</td>
<td>
<!--AVFP-> <input type="radio" name="clientval" value="1" <%=IIF(osession.VALUE("Client")="1",[checked],[])%> > -->
<input type="radio" name="clientval" value="1" >
Male<br>
<!--AVFP-> <input type="radio" name="clientval" value="2" <%=IIF(osession.VALUE("Client")="2",[checked],[])%> > -->
<input type="radio" name="clientval" value="2" >
Female<br>
 <!--AVFP->   <input type="radio" name="clientval" value="3" <%=IIF(osession.VALUE("Client")="3",[checked],[])%> > -->             
<input type="radio" name="clientval" value="3" checked >
Android<br>
<!--AVFP-> <input type="radio" name="clientval" value="4" <%=IIF(osession.VALUE("Client")="4",[checked],[])%> > -->
<input type="radio" name="clientval" value="4" >
Metrosexual
</td>
</tr>

6. Changes made in customer.dbf field:

Add a character field called "client"

7. Changes in main.prg as follows:

FUNCTION RecordDetail
...
oSession.VALUE("client",    ALLTRIM(Customer.client))

...

FUNCTION VerifyDetail
...
oSession.VALUE("client",    oRequest.FORM("clientval"))
...

FUNCTION thanks
...
client=    oSession.VALUE("client");
...

* * *

Hope to create a survey application using this radio button code.

Let me know if this is useful to anyone or if you have any other ideas on getting a survey application launched.


Coordinator
Feb 19, 2011 at 10:56 PM

Looks good!  I actually did a big survey system once for an insurance company using west-wind!!

Feb 20, 2011 at 11:18 AM

I've try your example, but get error message:

Caught .NET exception, source: 000349bd0004 err#= 11 line= 16 Function argument value, type, or count is invalid.11 Function argument value, type, or count is invalid. .NULL. .NULL. .NULL. .NULL. .NULL. D:\Hosting\6825460\html\avp\activevfp.dll message: D:\Hosting\6825460\html\avp\activevfp.dll

Feb 26, 2011 at 4:33 AM
Edited Feb 26, 2011 at 4:35 AM

HI onytoo,

I'm playing around with my website, so I may have changed (and broken the example).   But I gave the instructions
for duplicating what I did.

In the next few weeks I hope to have a rudimentary survey form to show.