Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何从表单到iframe获取输入框值? 函数showIFrame(){ var iframe=document.getElementById(“输出”); iframe.style.display=“block”; } 输入文本_Javascript_Jquery_Html_Forms_Iframe - Fatal编程技术网

Javascript 如何从表单到iframe获取输入框值? 函数showIFrame(){ var iframe=document.getElementById(“输出”); iframe.style.display=“block”; } 输入文本

Javascript 如何从表单到iframe获取输入框值? 函数showIFrame(){ var iframe=document.getElementById(“输出”); iframe.style.display=“block”; } 输入文本,javascript,jquery,html,forms,iframe,Javascript,Jquery,Html,Forms,Iframe,我需要获取该输入值并将其保存在iframeSrc=“/00ON0000000FOHS?pv2=(值)”? 我该怎么做 <html> <script src="http://code.jquery.com/jquery-1.8.3.js" type="text/javascript"></script> <script type="text/javascript"> function showIFrame() { var url='/00ON

我需要获取该输入值并将其保存在iframe
Src=“/00ON0000000FOHS?pv2=(值)”
? 我该怎么做

<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>
它必须获取值并加载

试试这个

<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>
<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>

函数showIFrame()
{
var url='/00ON0000000FOHS?pv2=('+$('#pv2').val()+');
$(“#输出”).show();
$('#output').attr('src',url);
}
输入文本

是的,这应该是可能的,即使该站点来自另一个域

<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>

我建议您将
数据src
属性添加到iframe

<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>
JavaScript

<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();
    });
HTML:

<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>


iframe的ID是
output
myiframe
?抱歉,输出不是myiframe谢谢您的回答,但它不会刷新iframe它会在您的函数调用不在我这边工作时刷新iframe src值。当我们直接给出src=“/00ON0000000FOHS?pv2=account3”时,它接受iframe并显示相同的内容。是否有任何方法可以直接从文本框中获取。我曾经这样尝试过src=“/00ON0000000FOHS?pv2=$('#pv2').val()”。这也不起作用。然后我试着用这个var url='/00ON0000000FOHS?pv2=account3'直接赋值来检查这一点是不可取的。你能建议其他方法吗