[英]How to echo value from input box (<form name=“form1”>) to input box (<form name=“form2”>)
[英]How to get the input box value from form to iframe?
<html>
<script type="text/javascript">
function showIFrame() {
var iframe = document.getElementById("output");
iframe.style.display="block";
}
</script>
<form method="get" name="search" id="search" target="carsearch">
<b>Enter Text</b><input type="text" id="pv2" name="pv2"/>
<input type="submit" value="Report Generation" class="submitBtn" id="SearchCarButton" onclick="showIFrame()"/>
<iframe id="output" style="border:1px solid;width:1000px;height:500px;" src="/00ON0000000FOHS?pv2=" name="carsearch">
</iframe>
</form>
</html>
我需要獲取該輸入值並將其保存在iframe中Src="/00ON0000000FOHS?pv2=(value)"
嗎? 我怎樣才能做到這一點?
它必須取值並加載
嘗試這個
<html>
<script src="http://code.jquery.com/jquery-1.8.3.js" type="text/javascript"></script>
<script type="text/javascript">
function showIFrame()
{
var url='/00ON0000000FOHS?pv2=('+$('#pv2').val()+')';
$('#output').show();
$('#output').attr('src', url);
}
</script>
<form method="get" name="search" id="search" target="carsearch">
<b>Enter Text</b><input type="text" id="pv2" name="pv2"/>
<input type="submit" value="Report Generation" class="submitBtn" id="SearchCarButton" onclick="showIFrame()"/>
<iframe id="output" style="display:none;border:1px solid;width:1000px;height:500px;" src="/00ON0000000FOHS?pv2=" name="carsearch">
</iframe>
</form>
</html>
是的,即使該站點來自另一個域,也應該可行。
$('input:button[name=save]').click(function() {
var name = $('iframe[name=select_frame]').contents().find('#select_name').val();
});
我建議您將data-src
屬性添加到iframe
JavaScript的
function showIFrame() {
var myIframe = $('#output');
myIframe.attr('src', myIframe.attr('data-src') + $('#pv2').val());
myIframe.show();
}
HTML:
<iframe id="output" src="" data-src="/00ON0000000FOHS?pv2=" name="carsearch" style="display:none;border:1px solid;width:1000px;height:500px;" >
</iframe>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.