在javascript中将两个变量作为字符串传递

时间:2014-02-27 11:24:09

标签: javascript html

我在javascript的html页面中收到错误 我试图在函数中传递字符串变量 PFB代码

document.write('<input type = "submit" value = "Details" class = "myButton" onClick = "dealerDetailsService(\''+orderDate+'\,\''+dealerCode+'\')"></input>');

给出错误

Expected ')'

1 个答案:

答案 0 :(得分:4)

在第一个参数之后你忘记了'

document.write('<input type="submit" value="Details" 
                   class="myButton" 
                   onClick="dealerDetailsService(\''+orderDate+'\',\''+dealerCode+'\')" />'); 
                                                                 ^ here