使用mvc 4使用javascript调用弹出窗口

时间:2014-05-15 15:49:57

标签: javascript asp.net-mvc-4 popupwindow

------Javascript function-------


<script>
function myFunction() {


    var form = window.document.getElementById(FormM);
    var paarno = window.document.getElementById(PAARNo);
    var url = "?FomM=" + form + "?PAARNo=" + paarno;
    //console.log(@Model.fbInfo.FormMNumber);
    window.open("Printfeedback"+url, "_blank", " resizable=no, top=500, left=500, width=400, height=400");
}
</script>


<button onclick="myFunction()" >Display window</button>



 <td align="left" class="style11"> @Html.Label("PAAR NUMBER")</td>
        <td align="left" class="style5" id="PAARNo">
              @Html.DisplayFor(model => model.fbsearchResult.PAARNo)</td>
        <td align="left" class="style9"> @Html.Label("Form M Number")</td>
        <td align="left" id="FormM"> @Html.DisplayFor(model => model.fbsearchResult.MFNumber)</td>

我想在用户点击按钮后弹出printfeedback页面。它一直显示参数为null。我不知道什么是错的,也许有些东西我不见了。请问有人可以帮忙吗?感谢

1 个答案:

答案 0 :(得分:0)

变化:

var form = window.document.getElementById(FormM);
var paarno = window.document.getElementById(PAARNo);

要:

var form = window.document.getElementById('FormM');
var paarno = window.document.getElementById('PAARNo');

getElementById方法需要区分大小写的字符串。如果不将它括在引号中,它将假定您传递一个字符串变量,在这种情况下将是未定义的。

See this reference