gpt4 book ai didi

javascript - 将输入字段值附加到 .cshtml 页面上的 URL

转载 作者:行者123 更新时间:2023-12-03 03:28:45 24 4
gpt4 key购买 nike

我的 .cshtml 页面中有一个 SSRS 报告的链接:

<div class="col-md-8">
<a href="http://xxx.xx.xx.x/ReportServer/Pages/ReportViewer.aspx?%2fCompany_Reporting%2fpayr0001&rs:Command=Render&StartDate=01/09/2017" target="_blank" >Timesheet Status Report</a>
</div>

我需要将日期控件中的值作为参数传递,而不是上面的硬编码日期:

<div class="form-group">
<input type="date" class="form-control" id="datefrom">
</div>

我尝试将 onclick=myfunction() 附加到网址以添加日期值,但无法使其正常工作。

function getStartDate() {
return document.getElementById("datefrom").value;
}

任何帮助将不胜感激。

干杯。

最佳答案

在日期更改属性上创建 anchor 标记的 href。随时随地构建 href。

$('#datefrom').change(function(){
$('#IdOfAnchorTag').attr('href','http://xxx.xx.xx.x/ReportServer/Pages/ReportViewer.aspx?%2fCompany_Reporting%2fpayr0001&rs:Command=Render&StartDate=' + $('#datefrom').val() );
});

相应地检查字符串..

关于javascript - 将输入字段值附加到 .cshtml 页面上的 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46187667/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com