Pav*_*van 8 html javascript prototypejs ruby-on-rails-3
我有以下代码,我得到了奇怪的错误.
function export_to_excel()
{
results_html = $('report_excel').innerHTML;
results_html = '<html><body><table align="center" cellspacing="0" cellpadding="0" width="100%"><tr><td colspan="9"><b>Employee Salary Register </b></td></tr><tr><td colspan="9"></td></tr>' + results_html + '</table></body></html>';
var input = new Element('input', {
'type': 'hidden',
'name': 'results[html]',
'value': results_html
});
var form = new Element('form', {
'method': 'post',
'name': 'Employee Salary Register',
'action': "html_to_excel"
});
form.insert(input);
document.body.appendChild(form);
form.submit();
}
Run Code Online (Sandbox Code Playgroud)
错误发生在此行
results_html = '<html><body><table align="center" cellspacing="0" cellpadding="0" width="100%"><tr><td colspan="9"><b>Employee Salary Register </b></td></tr><tr><td colspan="9"></td></tr>' + results_html + '</table></body></html>';
Run Code Online (Sandbox Code Playgroud)
编辑:
错误显示在指向该行的Firebug控制台中. 我只是附加了一个屏幕截图
在那里你可以看到,在两个按钮(打印和导出)下,代码出现在屏幕上.这些代码行是功能的一部分 export_to_excel()
它在我的本地服务器中也能很好地工作.我正在使用PrototypeJS,我很抱歉误导,也很抱歉.
任何帮助将不胜感激
我已经在下面实现了您的代码,并且效果很好 首先在这一行中首先定义您的 id/classresults_html = $('report_excel').innerHTML;
function export_to_excel(){
results_html = $('report_excel').innerHTML;
results_html = "<html><body><table align='center' cellspacing='0' cellpadding='0' width='100%'><tr><td colspan='9'><b>Employee Salary Register </b></td></tr><tr><td colspan='9'></td></tr>" + results_html + "</table></body></html>";
var input = new Element('input', {
'type': 'hidden',
'name': 'results[html]',
'value': results_html
});
var form = new Element('form', {
'method': 'post',
'name': 'Employee Salary Register',
'action': "html_to_excel"
});
form.insert(input);
document.body.appendChild(form);
form.submit();
}
Run Code Online (Sandbox Code Playgroud)