![](/img/trans.png)
[英]How can we send a jquery amount filed in hidden in php for another page to retrieve the amount value?
[英]Jquery how send hidden value to my script
我使用ASP.NET MVC和Jquery。 我有圖標,當我單擊它時會顯示對話框。
Reports.cshtml:
<a class="dialog-opener" href="#">
<input type="hidden" name="reportID" value="@view.ReportCode"/>
<i class="material-icons right">more_vert</i>
</a>
在此對話框中,我有一個窗體,它是局部視圖SubscriptionForm.cshtml:
<div id="dialog-modal" title="Basic model dialog">
@using (Html.BeginForm("SubscriptionForm", "Subscription", FormMethod.Get)) {
@Html.AntiForgeryToken()
...
</div>
_LayoutForAll.chhtml:
$(function () {
$('#dialog-modal').dialog({
dialogClass: 'ui-dialog-osx',
autoOpen: false,
width: 800,
title:"Formularz subskrypcji",
show: {
duration: 1000
},
hide: {
duration: 1000
}
});
$('.dialog-opener').click(function () {
var reportId = $("[type=hidden]").val();
$("#dialog-modal").dialog("open");
alert(reportId);
});
});
我需要從Reports.cshtml發送reportId,並從表單SubscriptionForm發送日期到我的控制器,我現在不怎么做。
為您的隱藏文件提供ID並使用jquery獲取價值
<a class="dialog-opener" href="#">
<input type="hidden" id="myhiddenfield" name="reportID" value="@view.ReportCode"/>
<i class="material-icons right">more_vert</i>
</a>
下面的代碼用於從隱藏字段中獲取價值。
$('.dialog-opener')
.click(function () {
var reportId = $("#myhiddenfield").val();
$("#dialog-modal").dialog("open");
alert(reportId);
});
試試上面的代碼。 它的工作正常。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.