html 将下拉值作为URL参数发送。如果我们的系统预先填写表单,则不起作用。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html 将下拉值作为URL参数发送。如果我们的系统预先填写表单,则不起作用。相关的知识,希望对你有一定的参考价值。

<!-- START code for sending selected dropdown value to the TY page as URL parameter -->
<script>
    $(document).ready(function() {
        //define function that appends the parameter to the redirect URL
        var sendAsParameter = function(selectedOptionParam) {
            var redirectUrl = $('form.email-form').find('input[name="redirect"]').val();
            //clean the url of any old parameters
            var cleanRedirectUrl = redirectUrl.match(/.+\.hollard\.co\.za\//g);
            $('form.email-form').find('input[name="redirect"]').val(cleanRedirectUrl[0] + "?product=" + selectedOptionParam);
        };
        //define on change event for dropdown
        $('select[name="' + window.btoa('CHOOSE PRODUCT*') + '"]').change(function(e) {
            //get the option
            selectedOptionArg = this.options[e.target.selectedIndex].text;
            //cosmetize value
            selectedOptionArg = selectedOptionArg.replace(' ', '-');
            //append the value and the parameter to the redirect URL
            sendAsParameter(selectedOptionArg);
        });
    });

</script>
<!-- END code for sending selected dropdown value to the TY page as URL parameter -->

以上是关于html 将下拉值作为URL参数发送。如果我们的系统预先填写表单,则不起作用。的主要内容,如果未能解决你的问题,请参考以下文章