简体   繁体   English

Javascript生成的Submit按钮不在Firefox中发布

[英]Javascript-Generated Submit Button Not POSTing in Firefox

I have seen similar posts related to this question but none have proven useful. 我见过与此问题相关的类似帖子,但没有一个被证明有用。

I have a several javascript-generated submit buttons for a form. 我有几个由javascript生成的表单提交按钮。

PHP sets certain parameters for functions depending on which button is pushed. PHP根据按下哪个按钮为功能设置某些参数。 The problem is that the submit buttons do not get added to the POST array AT ALL if they are generated by javascript; 问题在于,如果提交按钮是由javascript生成的,则它们根本不会添加到POST数组中。 If I put submit buttons directly into the view they work just fine. 如果我将提交按钮直接放入视图中,它们就可以正常工作。 This is only a problem in Firefox 这只是Firefox中的问题

NOTE: this is not a problem with the form actually submitting - just that the name=>value of the submit button is not being passed to POST. 注意:这与实际提交的表单无关,只是没有将提交按钮的name => value传递给POST。

$('#my-total-dial').highcharts(Highcharts.merge(gaugeOptions, {
    yAxis: {
        min: 0,
        max: myTotalRecords,
        title: {
          text: 'All Time'
        }
    },

    credits: {
        enabled: false
    },

    series: [{
        name: 'All',
        data: [myTotalRecords],
        dataLabels: {
            format: '<div style="text-align:center"><span style="font-size:18px;color:' +
                ((Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black') + '">{y}</span><br/></div>' +
                   '<button name="my-total-records-view" class="glyphicon glyphicon-eye-open" title="View Records"></button><button name="my-total-records-csv" class="glyphicon glyphicon-file" title="Export Records to Spreadsheet"></button>'
        },
        tooltip: {
            valueSuffix: ' records'
        }
    }]

}));

In Chrome, this is what is spit out by POST: 在Chrome中,这是POST吐出的内容:

array(3) { ["_token"]=> string(40) "XB16S144KnTue3ER6x4H8mdQO1rwxGP6BmAciYvK" ["my-total-records-view"]=> string(6) "Submit" ["user_name"]=> string(1) "1" }

And this is what I get in Firefox 这就是我在Firefox中得到的

array(2) { ["_token"]=> string(40) "UTKWISXMNvUfGjfFxxya8ojYXSgGc8dS5kUS5Hck" ["user_name"]=> string(1) "1" } 

By default <button> elements does not submit the form. 默认情况下, <button>元素不提交表单。 Use <input type='submit'> instead. 使用<input type='submit'>代替。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM