Page 1 of 1

HTML form submit to fieldname/fieldvalue table

PostPosted: Wed May 27, 2015 5:29 pm
by Westy
We want to allow our customers to do a html form submit from their website that will place the submitted data into a fieldname/fieldvalue table that can be accessed by our Servoy solution. The html submit form must be within their own html file (not a Servoy form).

What would a Servoy method look like that can receive the data, parse it, and place it into the fieldname/fieldvalue table? We will not know the field names, nor the number of fieldname/fieldvalue pairs to be submitted in advance.

Dean

Re: HTML form submit to fieldname/fieldvalue table

PostPosted: Wed May 27, 2015 9:04 pm
by ROCLASI
Hi Dean,

So the form is hosted on their own website?

You could use the Velocity plugin for this.

Your HTML form would be something like this:
Code: Select all
<form action="http://my.server.domain/myWebformProcessor/" method="post">
    <!-- all your fields and perhaps submit button -->
</form>

Your method would then look something like this:
Code: Select all
function vr_getContext(request) {
    if ( request.method === 'POST') { // sanity check
        // Get an array with all the parameter names (which corresponds with the field names in the web form)
        var _aParamKeys = Object.keys(request.parameters);
        for (var i = 0; i < _aParamKeys.length; i++) {
            foundset.newRecord();
            // I guess you want to add some identifying value here as well
   
            // store the key/value
            foundset.fieldName = _aParamKeys[i];
            foundset.fieldValue = request.parameters[_aParamKeys[i]];
        }
   
        // return a response (see Velocity Wiki)
    } else {
        // not a POST, handle accordingly. For example return a 403 (not allowed)
    }
}


Hope this helps

Re: HTML form submit to fieldname/fieldvalue table

PostPosted: Wed May 27, 2015 10:38 pm
by Westy
Thank you very much.
Dean