我陷入了一个问题。从其他页面加载html页面并在填充页面的文本框中预填充值
问题是:
我需要加载HTML页面(说的test.html)上的一些页面(比如主页)点击按钮。
现在test.html包含一些输入框,我需要在加载test.html时预先填充。
内容 主页
<body>
<h1> Page 1 </h1>
<div id="topBar">
<a href ="#" id="load_home" onclick="load_home()"> HOME </a>
</div>
<div id ="content">
</div>
</div>
</body>
<script type="text/javascript">
$(document).ready(function(){
document.getElementById("content").innerHTML='<object type="text/html" data="test.html" ></object>';
document.getElementsByClassName('monday_spends').setAttribute("value", "yolo");
});
</script>
test.html中包含
<table class="ss-moneyDetails">
<tr>
<th>Details:</th>
</tr>
<tr>
<td>Monday</td>
<td><i class="ss-iconRupee">₹</i><span>
<input class="monday_spends" type="text" value="" name="monday_spends"/>20,000</span></td>
</tr>
</table
我需要预填的<input class="monday_spends" type="text" value="" name="monday_spends"/>
价值,同时加载从home.html的页面test.html文件。
注意:我也试图通过调用一个ajax请求,以满足html页面和预填数据。是否有可能? 我错过了什么吗?
你不需要JavaScript为此,只需更改网址 – Roberrrt
就像test.html&money_spends = 20000 – Roberrrt
我没有得到你。你能解释一下吗? –