簡體   English   中英

在頁面加載時,在javascript中的文本框中顯示值

[英]On page load show the value in textbox in javascript

我正在使用asp.net mvc2。

JavaScript代碼:

$(document).ready(function () {
          $("#candidatecontact").hide();              
          document.getElementById("counting").value =  '<%=ViewData["ResumesCount"] %>';
            $('#butt2').click(function () 
            {
                 count();
            });
        });    

function count() {               
             var tempId = <%=Model.Id%>; 
             var url = '/Page/Count';
             $.ajax({
                    type: "GET",
                    url: url,
                    data: { id : tempId}, 
                    dataType: "int",
                    success : function (count) {                            
                        SetCount(count);                            
                    }
                });                                     
        }

HTML代碼:

<% ViewData["ResumesCount"] = remainingHorsCount; %>
<input id = "counting" type = "text" style="width:20px;"/>

當上述文本框中的頁面加載顯示ViewData["ResumesCount"] ..的值時,請給我一些想法嗎?

嘗試

<input id = "counting" type = "text" value="<%= remainingHorsCount%>" style="width:20px;"/>

要么

<input id = "counting" type = "text" value="<%= ViewData['ResumesCount']%>" style="width:20px;"/>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM