Example #1
0
function qpp_error_page($id)
{
    qpp_change_form_update();
    if (isset($_POST['Submit']) && check_admin_referer("save_qpp")) {
        $options = array('errortitle', 'errorblurb');
        foreach ($options as $item) {
            $error[$item] = stripslashes($_POST[$item]);
            $error[$item] = filter_var($error[$item], FILTER_SANITIZE_STRING);
        }
        update_option('qpp_error' . $id, $error);
        qpp_admin_notice("The error settings have been updated.");
    }
    if (isset($_POST['Reset']) && check_admin_referer("save_qpp")) {
        delete_option('qpp_error' . $id);
        qpp_admin_notice("The error messages have been reset.");
    }
    $qpp_setup = qpp_get_stored_setup();
    $id = $qpp_setup['current'];
    $error = qpp_get_stored_error($id);
    qpp_create_css_file('update');
    $content = '<div class="qpp-settings"><div class="qpp-options">';
    if ($id) {
        $content .= '<h2>Eror message settings for ' . $id . '</h2>';
    } else {
        $content .= '<h2>Default form error message</h2>';
    }
    $content .= qpp_change_form($qpp_setup);
    $content .= '<form method="post" action="">
    <p<span<b>Note:</b> Leave fields blank if you don\'t want to use them</span></p>
    <table>
    <tr>
    <td>Error header</td>
    <td><input type="text"  style="width:100%" name="errortitle" value="' . $error['errortitle'] . '" /></td>
    </tr>
    <tr>
    <td>Error message</td>
    <td><input type="text" style="width:100%" name="errorblurb" value="' . $error['errorblurb'] . '" /></td>
    </tr>
    </table>
    <p><input type="submit" name="Submit" class="button-primary" style="color: #FFF;" value="Save Changes" /> <input type="submit" name="Reset" class="button-primary" style="color: #FFF;" value="Reset" onclick="return window.confirm( \'Are you sure you want to reset the error message?\' );"/></p>';
    $content .= wp_nonce_field("save_qpp");
    $content .= '</form>
    </div>
    <div class="qpp-options" style="float:right;">
    <h2>Error Checker</h2>
    <p>Try sending a blank form to test your error messages.</p>';
    if ($id) {
        $form = ' form="' . $id . '"';
    }
    $args = array('form' => $id, 'id' => '', 'amount' => '');
    $content .= qpp_loop($args);
    $content .= '<p>There are some more examples of payment forms <a href="http://quick-plugins.com/quick-paypal-payments/paypal-examples/" target="_blank">on this page</a>.</p>
    <p>And there are loads of shortcode options <a href="http://quick-plugins.com/quick-paypal-payments/paypal-payments-shortcodes/" target="_blank">on this page</a>.</p>
    </div></div>';
    echo $content;
}
function qpp_display_form($values, $errors, $id)
{
    $qpp_form = qpp_get_stored_setup();
    $qpp = qpp_get_stored_options($id);
    $error = qpp_get_stored_error($id);
    $coupon = qpp_get_stored_coupon($id);
    $send = qpp_get_stored_send($id);
    $style = qpp_get_stored_style($id);
    $currency = qpp_get_stored_curr();
    $address = qpp_get_stored_address($id);
    $curr = $currency[$id] == '' ? 'USD' : $currency[$id];
    $check = preg_replace('/[^.0-9]/', '', $values['amount']);
    $decimal = array('HKD', 'JPY', 'MYR', 'TWD');
    $d = '2';
    foreach ($decimal as $item) {
        if ($item == $currency[$id]) {
            $d = '0';
        }
    }
    $values['producttotal'] = $values['quantity'] * $check;
    $c = qpp_currency($id);
    $p = qpp_postage($qpp, $values['producttotal'], '1');
    $h = qpp_handling($qpp, $values['producttotal'], '1');
    $t = $id;
    if ($t == '') {
        $t = 'default';
    }
    $hd = $style['header-type'];
    $values['producttotal'] = $values['producttotal'] + $p + $h;
    $values['producttotal'] = number_format($values['producttotal'], $d, '.', '');
    global $_GET;
    if (isset($_GET["coupon"])) {
        $values['couponblurb'] = $_GET["coupon"];
        $values['couponget'] = $coupon['couponget'];
    }
    if ($id) {
        $formstyle = $id;
    } else {
        $formstyle = 'default';
    }
    if (!empty($qpp['title'])) {
        $qpp['title'] = '<' . $hd . '>' . $qpp['title'] . '</' . $hd . '>';
    }
    if (!empty($qpp['blurb'])) {
        $qpp['blurb'] = '<p>' . $qpp['blurb'] . '</p>';
    }
    $content = '<div class="qpp-style ' . $formstyle . '"><div id="' . $style['border'] . '">';
    if (count($errors) > 0) {
        $content .= "<" . $hd . " id='qpp_reload' style='color:" . $style['error-colour'] . ";'>" . $error['errortitle'] . "</" . $hd . ">\n        <script type='text/javascript' language='javascript'>document.querySelector('#qpp_reload').scrollIntoView();</script>\n        <p style='color:" . $style['error-colour'] . ";'>" . $error['errorblurb'] . "</p>";
        $arr = array('amount', 'reference', 'quantity', 'use_stock', 'answer', 'quantity', 'email', 'firstname', 'lastname', 'address1', 'address2', 'city', 'state', 'zip', 'country', 'night_phone_b');
        foreach ($arr as $item) {
            if ($errors[$item] == 'error') {
                $errors[$item] = ' style="border:1px solid ' . $style['error-colour'] . ';" ';
            }
        }
        if ($errors['useterms']) {
            $errors['useterms'] = 'border:1px solid ' . $style['error-colour'] . ';';
        }
        if ($errors['captcha']) {
            $errors['captcha'] = 'border:1px solid ' . $style['error-colour'] . ';';
        }
        if ($errors['quantity']) {
            $errors['quantity'] = 'border:1px solid ' . $style['error-colour'] . ';';
        }
    } else {
        $content .= $qpp['title'];
        if ($qpp['paypal-url'] && $qpp['paypal-location'] == 'imageabove') {
            $content .= "<img src='" . $qpp['paypal-url'] . "' />";
        }
        $content .= $qpp['blurb'];
    }
    $content .= '<form id="frmPayment' . $t . '" name="frmPayment' . $t . '" method="post" action="">';
    foreach (explode(',', $qpp['sort']) as $name) {
        switch ($name) {
            case 'field1':
                if (!$values['setref']) {
                    $required = !$errors['reference'] ? ' class="required" ' : '';
                    $content .= '<p>
                <input type="text" label="Reference" ' . $required . $errors['reference'] . 'name="reference" value="' . $values['reference'] . '" onfocus="qppclear(this, \'' . $values['reference'] . '\')" onblur="qpprecall(this, \'' . $values['reference'] . '\')"/>
                </p>';
                } else {
                    if ($values['combine']) {
                        $checked = 'checked';
                        $ret = array_map('explode_by_semicolon', explode(',', $values['reference']));
                        if ($qpp['refselector'] == 'refdropdown') {
                            $content .= qpp_dropdown($ret, $values, 'reference', $qpp['shortcodereference']);
                        } else {
                            $content .= '<p class="payment" >' . $qpp['shortcodereference'] . '<br>';
                            $content .= '<input type="hidden" name="combined_radio_amount" value="0.00" />';
                            foreach ($ret as $item) {
                                if (strrpos($values['reference'], $item[0]) !== false && $values['combine'] != 'initial') {
                                    $checked = 'checked';
                                }
                                $content .= '<label><input type="radio" style="margin:0; padding: 0; border:none;width:auto;" name="reference" value="' . $item[0] . '&' . $item[1] . '" ' . $checked . '> ' . $item[0] . ' ' . $item[1] . '</label><br>';
                                $checked = '';
                            }
                            $content .= '</p>';
                        }
                        $content .= '<input type="hidden" name="combine" value="checked" />';
                    } elseif ($values['explode']) {
                        $checked = 'checked';
                        $ref = explode(",", $values['reference']);
                        if ($qpp['refselector'] == 'refdropdown') {
                            $content .= qpp_dropdown($ref, $values, 'reference', $qpp['shortcodereference']);
                        } else {
                            $content .= '<p class="payment" >' . $qpp['shortcodereference'] . '<br>';
                            foreach ($ref as $item) {
                                $content .= '<label>
                            <input type="radio" style="margin:0; padding: 0; border:none;width:auto;" name="reference" value="' . $item . '" ' . $checked . '> ' . $item . '</label><br>';
                            }
                            $checked = '';
                            $content .= '</p>';
                        }
                    } else {
                        $content .= '<p class="input" >' . $values['reference'] . '</p><input type="hidden" name="reference" value="' . $values['reference'] . '" /><input type="hidden" name="setref" value="' . $values['setref'] . '" />';
                    }
                }
                break;
            case 'field2':
                if ($qpp['use_stock']) {
                    $required = !$errors['use_stock'] && $qpp['ruse_stock'] ? ' class="required" ' : '';
                    $content .= '<p>';
                    if ($qpp['fixedstock']) {
                        $content .= '<p class="input" >' . $values['stock'] . '<input type="hidden" name="stock" value="' . $values['stock'] . '" /></p>';
                    } else {
                        $content .= '<p><input type="text" ' . $required . $errors['use_stock'] . ' label="stock" name="stock" value="' . $values['stock'] . '" onfocus="qppclear(this, \'' . $values['stock'] . '\')" onblur="qpprecall(this, \'' . $values['stock'] . '\')"/>
                </p>';
                    }
                }
                break;
            case 'field3':
                if ($qpp['use_quantity']) {
                    $content .= '<p>
                <span class="input">' . $qpp['quantitylabel'] . '</span>
                <input type="text" style=" ' . $errors['quantity'] . 'width:3em;margin-left:5px" id="qppquantity' . $t . '" label="quantity" name="quantity" value="' . $values['quantity'] . '" onfocus="qppclear(this, \'' . $values['quantity'] . '\')" onblur="qpprecall(this, \'' . $values['quantity'] . '\')" />';
                    if ($qpp['quantitymax']) {
                        $content .= '&nbsp;' . $qpp['quantitymaxblurb'];
                    }
                    $content .= '</p>';
                } else {
                    $content .= '<input type ="hidden" id="qppquantity' . $t . '" name="quantity" value="1">';
                }
                break;
            case 'field4':
                if ($qpp['use_slider']) {
                    $content .= '<p>' . $qpp['sliderlabel'] . '</p>
                <input type="range" id="qppamount' . $t . '" name="amount" min="' . $qpp['min'] . '" max="' . $qpp['max'] . '" value="' . $values['amount'] . '" step="' . $qpp['step'] . '" data-rangeslider>
                <div class="qpp-slideroutput">';
                    if ($qpp['output-values']) {
                        $content .= '<span class="qpp-sliderleft">' . $qpp['min'] . '</span>
                    <span class="qpp-slidercenter"><output></output></span>
                    <span class="qpp-sliderright">' . $qpp['max'] . '</span>';
                    } else {
                        $content .= '<span class="qpp-outputcenter"><output></output></span>';
                    }
                    $content .= '</div><div style="clear: both;"></div>';
                } else {
                    if (!$values['combine']) {
                        if (!$values['setpay']) {
                            $required = !$errors['amount'] ? ' class="required" ' : '';
                            $content .= '<p>
                        <input type="text" ' . $required . $errors['amount'] . ' id="qppamount' . $t . '" label="Amount" name="amount" value="' . $values['amount'] . '" onfocus="qppclear(this, \'' . $values['amount'] . '\')" onblur="qpprecall(this, \'' . $values['amount'] . '\' )" />
                        </p>';
                        } else {
                            if ($values['explodepay']) {
                                $ref = explode(",", $values['amount']);
                                if ($qpp['selector'] == 'dropdown') {
                                    $content .= qpp_dropdown($ref, $values, 'amount', $qpp['shortcodeamount']);
                                } else {
                                    $checked = 'checked';
                                    $br = $qpp['inline_amount'] ? '&nbsp;' : '<br>';
                                    $content .= '<p class="payment" >' . $qpp['shortcodeamount'] . '<br>';
                                    foreach ($ref as $item) {
                                        $content .= '<label><input type="radio" id="qpptiddles" style="margin:0; padding: 0; border:none;width:auto;" name="amount" value="' . $item . '" ' . $checked . '> ' . $item . '</label>' . $br;
                                        $checked = '';
                                    }
                                    $content .= '</p>';
                                }
                            } else {
                                $content .= '<p class="input" >' . $values['amount'] . '</p><input type="hidden" id="qppamount' . $t . '" name="amount" value="' . $values['fixedamount'] . '" />';
                            }
                        }
                        $content .= '<input type="hidden" name="radio_amount" value="0.00" />';
                    }
                }
                break;
            case 'field5':
                if ($qpp['use_options']) {
                    $content .= '<p class="input">' . $qpp['optionlabel'] . '</p><p>';
                    $arr = explode(",", $qpp['optionvalues']);
                    if ($qpp['optionselector'] == 'optionsdropdown') {
                        $content .= qpp_dropdown($arr, $values, 'option1', '');
                    } else {
                        foreach ($arr as $item) {
                            $checked = '';
                            if ($values['option1'] == $item) {
                                $checked = 'checked';
                            }
                            if ($item === reset($arr)) {
                                $content .= '<input type="radio" style="margin:0; padding: 0; border: none" name="option1" value="' . $item . '" id="' . $item . '" checked><label for="' . $item . '"> ' . $item . '</label><br>';
                            } else {
                                $content .= '<input type="radio" style="margin:0; padding: 0; border: none" name="option1" value="' . $item . '" id="' . $item . '" ' . $checked . '><label for="' . $item . '"> ' . $item . '</label><br>';
                            }
                        }
                        $content .= '</p>';
                    }
                }
                break;
            case 'field6':
                if ($qpp['usepostage']) {
                    $content .= '<p class="input" >' . $qpp['postageblurb'] . '</p>';
                }
                break;
            case 'field7':
                if ($qpp['useprocess']) {
                    $content .= '<p class="input" >' . $qpp['processblurb'] . '</p>';
                }
                break;
            case 'field8':
                if ($qpp['captcha']) {
                    $required = !$errors['captcha'] ? ' class="required" ' : '';
                    if (!empty($qpp['mathscaption'])) {
                        $content .= '<p class="input">' . $qpp['mathscaption'] . '</p>';
                    }
                    $content .= '<p>' . strip_tags($values['thesum']) . ' = <input type="text" ' . $required . ' style="width:3em;font-size:100%;' . $errors['captcha'] . '" label="Sum" name="maths"  value="' . $values['maths'] . '"></p> 
                <input type="hidden" name="answer" value="' . strip_tags($values['answer']) . '" />
                <input type="hidden" name="thesum" value="' . strip_tags($values['thesum']) . '" />';
                }
                break;
            case 'field9':
                $content .= '<input type="hidden" name="couponapplied" value="' . $values['couponapplied'] . '" />';
                if ($qpp['usecoupon'] && $values['couponapplied']) {
                    $content .= '<p>' . $qpp['couponref'] . '</p>
                <input type="hidden" name="couponblurb" value="' . $values['couponblurb'] . '" />';
                }
                if ($qpp['usecoupon'] && !$values['couponapplied']) {
                    if ($values['couponerror']) {
                        $content .= '<p style="color:' . $style['error-colour'] . ';">' . $values['couponerror'] . '</p>';
                    }
                    $content .= '<p>' . $values['couponget'] . '</p>';
                    $content .= '<p><input type="text" label="coupon" name="couponblurb" value="' . $values['couponblurb'] . '" onfocus="qppclear(this, \'' . $values['couponblurb'] . '\')" onblur="qpprecall(this, \'' . $values['couponblurb'] . '\')"/>
                </p>
                <p class="submit">
                <input type="submit" value="' . $qpp['couponbutton'] . '" id="couponsubmit" name="qppapply' . $id . '" />
                </p>';
                }
                break;
            case 'field10':
                if ($qpp['useterms']) {
                    if ($qpp['termspage']) {
                        $target = ' target="blank" ';
                    }
                    $required = !$errors['useterms'] ? 'border:' . $style['required-border'] . ';' : $errors['useterms'];
                    $color = $errors['useterms'] ? ' style="color:' . $style['error-colour'] . ';" ' : '';
                    $content .= '<p class="input" ' . $errors['useterms'] . '>
                <input type="checkbox" style="margin:0; padding: 0;width:auto;' . $required . '" name="termschecked" value="checked" ' . $values['termschecked'] . '>
                &nbsp;
                <a href="' . $qpp['termsurl'] . '"' . $target . $color . '>' . $qpp['termsblurb'] . '</a></p>';
                }
                break;
            case 'field11':
                if ($qpp['useblurb']) {
                    $content .= '<p>' . $qpp['extrablurb'] . '</p>';
                }
                break;
            case 'field12':
                if ($qpp['userecurring']) {
                    $content .= '<p>' . $qpp['recurringblurb'] . '<br>
                ' . $qpp['payments'] . ' ' . $qpp['srt'] . '<br>
                ' . $qpp['every'] . ' ' . $qpp['recurringhowmany'] . ' ' . $qpp['recurringperiod'] . '</p>';
                    $checked = 'checked';
                    $ref = explode(",", $values['recurring']);
                }
                break;
            case 'field13':
                if ($qpp['useaddress']) {
                    $content .= '<p>' . $qpp['addressblurb'] . '</p>';
                    $arr = array('firstname', 'lastname', 'email', 'address1', 'address2', 'city', 'state', 'zip', 'country', 'night_phone_b');
                    foreach ($arr as $item) {
                        if ($values[$item]) {
                            $required = $address['r' . $item] && !$errors[$item] ? ' class="required" ' : '';
                            $content .= '<input type="text" name="' . $item . '" ' . $required . $errors[$item] . ' value="' . $values[$item] . '" onfocus="qppclear(this, \'' . $values[$item] . '\')" onblur="qpprecall(this, \'' . $values[$item] . '\')"/>';
                        }
                    }
                }
                break;
            case 'field14':
                if ($qpp['usetotals']) {
                    $content .= '<p style="font-weight:bold;">Total: ' . $c['b'] . '<input type="text" id="qpptotal" name="total" value="0.00" readonly="readonly" />' . $c['a'] . '</p>';
                } else {
                    $content .= '<input type="hidden" id="qpptotal" name="total"  />';
                }
                break;
            case 'field16':
                if ($qpp['useemail'] && !$qpp['useaddress']) {
                    $content .= '<input type="text" label="stock" name="email" value="' . $values['email'] . '" onfocus="qppclear(this, \'' . $values['email'] . '\')" onblur="qpprecall(this, \'' . $values['email'] . '\')"/>';
                }
                break;
        }
    }
    $caption = $qpp['submitcaption'];
    if ($style['submit-button']) {
        $content .= '<p class="submit"><input type="image" id="submitimage" value="' . $caption . '" src="' . $style['submit-button'] . '" name="qppsubmit' . $id . '" onClick="replaceContentInContainer(\'place' . $id . '\', \'rep_place' . $id . '\')"/></p>';
    } else {
        $content .= '<p class="submit"><input type="submit" value="' . $caption . '" id="submit" name="qppsubmit' . $id . '" /></p>';
    }
    if ($qpp['use_reset']) {
        $content .= '<p><input type="reset" value="' . $qpp['resetcaption'] . '" /></p>';
    }
    $content .= '</form>' . "\r\t";
    if ($qpp['paypal-url'] && $qpp['paypal-location'] == 'imagebelow') {
        $content .= '<img src="' . $qpp['paypal-url'] . '" />';
    }
    if ($qpp['usetotals'] || $qpp['use_slider']) {
        $content .= '<script type="text/javascript">
        (function() {
            function formatDecimal(val, n) {
                n = n || 2;
                var str = "" + Math.round ( parseFloat(val) * Math.pow(10, n) );
                while (str.length <= n) {
                    str = "0" + str;
                }
                var pt = str.length - n;
                return str.slice(0,pt) + "." + str.slice(pt);
            }
            function getRadioVal(form, name) {
                var radios = form.elements[name];
                var val;
                for (var i=0, len=radios.length; i<len; i++) {
                    if ( radios[i].checked == true ) {
                        val = radios[i].value;
                        break;
                    }
                }
                return val;
            }
            function getSizePrice(e) {
                this.form.elements["radio_amount"].value = this.value;
                updateTotal' . $t . '(this.form);
            }
            function getquantity() {
                this.form.elements["qppquantity' . $t . '"].value = this.value;
                updateTotal' . $t . '(this.form);
            }
            function getamount() {
                this.form.elements["qppamount' . $t . '"].value = this.value;
                updateTotal' . $t . '(this.form);
            }
            function updateTotal' . $t . '(form, explicitAmount) {
                
                if (typeof optionalArg === "undefined"){
                    if(form.elements["quantity"]) {
                        var qty = form.elements["quantity"].value;
                    } else {
                        var qty = parseFloat( form.elements["qppquantity' . $t . '"].value );
                    }
                    qty = qty || 1;
                    if ("' . $values['explodepay'] . '"=="checked" && form.elements["radio_amount"]) {
                        var radio_amount = form.elements["radio_amount"].value;
                        var radio_amount = Number(radio_amount.replace(/[^0-9\\.]+/g,""));
                        var radio_amount = parseFloat(radio_amount);
                    } else if (form.elements["combined_radio_amount"] ) {
                        var radio_amount = form.elements["combined_radio_amount"].value;
                    } else {
                        var amount = form.elements["qppamount' . $t . '"].value;
                        var amount = Number(amount.replace(/[^0-9\\.]+/g,""));
                        var amount = parseFloat(amount);
                    }
                    
                    amount = amount || 0;
                    radio_amount = radio_amount || 0;
                    var m = qty * (amount + radio_amount);
                } else {
                    var m = explicitAmount;
                }
                var h = 0;
                var p = 0;
                if ("' . $qpp['useprocess'] . '" == "checked") {
                    
                    if ("' . $qpp['processtype'] . '" == "processpercent"){
                        
                        var h = "' . $qpp['processpercent'] . '".replace( /^\\D+/g, "");
                        
                        var h = (m * h / 100);
                        
                    } else {
                        var h = "' . $qpp['processfixed'] . '".replace( /^\\D+/g, "") * 1;
                        
                    }
                }
                if ("' . $qpp['usepostage'] . '" == "checked") {
                    if ("' . $qpp['postagetype'] . '" == "postagepercent"){
                        var p = "' . $qpp['postagepercent'] . '".replace( /^\\D+/g, "");
                        
                        var p = (m * p / 100);
                    } else {
                        var p = "' . $qpp['postagefixed'] . '".replace( /^\\D+/g, "") * 1;
                        
                    }
                }
                //console.log("m"+m + " p"+p + " h"+h);
                form.elements["total"].value = formatDecimal(m + p + h);
            }
            var form = document.getElementById("frmPayment' . $t . '");
            if ("' . $values['explodepay'] . '"=="checked") {
                var sz = form.elements["amount"];
                for (var i=0, len=sz.length; i<len; i++) sz[i].onclick = getSizePrice;
                form.elements["radio_amount"].value = Number( getRadioVal(form, "amount").replace(/[^0-9\\.]+/g,""));
                updateTotal' . $t . '(form);
            } else if(document.getElementById("qppamount' . $t . '")) {
                var bx = document.getElementById("qppamount' . $t . '");
                bx.onkeyup = getamount;
                getamount.call(bx);
            }
            var ax = document.getElementById("qppquantity' . $t . '");
            ax.onkeyup = getquantity;
            getquantity.call(ax);
            jQuery(document).ready(function($) {
                $(function() {                    
                    var $document = $(document),selector = "[data-rangeslider]",$inputRange = $(selector);function valueOutput(element) {
                        var value = element.value,output = element.parentNode.getElementsByTagName("output")[0];
                        output.innerHTML = value;
                    }
                    for (var i = $inputRange.length - 1; i >= 0; i--) {
                        valueOutput($inputRange[i]);
                    };
                    $document.on("change", selector, function(e) {
                        valueOutput(e.target);
                    });
                    $inputRange.rangeslider({
                        polyfill: false,onSlide: function(position, value) {
                            updateTotal' . $t . '(document.getElementById("frmPayment' . $t . '"), value);
                        }
                    });
                });
            });
            jQuery(document).ready(function($) {
                combined = [];
                initiate = [];
                numeric_regex = /[+\\-0-9\\.\\,]+/;
                jQuery("input[type=radio]").each(function(index){
                    if($(this).attr("value").match(/\\&/) && $(this).attr("name").match(/reference/)) {
                        combined.push($(this));
                        if($(this).attr("checked")) {
                            initiate.push($(this));
                        }
                    }
                })
                
                $.each(combined, function(key, val){
                
                    val.change(function(){
                        v = val.val();
                        split = v.split("&");
                        numeric = split[1].match(numeric_regex);
                        //console.log("combined "+numeric[0]);
                        formid = $(this).closest("form").attr("id");
                        $("#"+ formid + " input[name=combined_radio_amount]").val(numeric[0]);
                        updateTotal' . $t . '(document.getElementById(formid));
                    });
                });
                $.each(initiate, function(key, val){
                    val.change();
                });
            });
    }());
</script>';
    }
    $content .= '<script>jQuery("select option:selected").click(); //force calculation by clicking on default values</script>';
    $content .= '<div style="clear:both;"></div></div></div>' . "\r\t";
    echo $content;
}