2016-05-23 42 views
1

我想要在页面内打印图像。这里是我的代码如何在页面中获取并打印图像php

<form method="post" action="" enctype="multipart/form-data"> 
 
    <input type="radio" value="<img src='images/image1.jpg'>"> 
 
    <img src="images/image1.jpg" width="50px" height="50px"><br/> 
 
    <input type="radio" value="<img src='images/image2.jpg'>"> 
 
    <img src="images/image2.jpg" width="50px" height="50px"><br/> 
 
    <input type="radio" value="Both" />Both<br/> 
 
</form> 
 

 
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> 
 
<script type="text/javascript"> 
 
    $("input:radio[type=radio]").click(function(){ 
 
     var value = $(this).val(); 
 
     $('#showoption').val(value); 
 
    }); 
 
</script> 
 

 
<label>Value</label> \t 
 
<input type="text" id="showoption" name="name" disabled="disabled"> \t 
 
</label>

当我点击选中的单选按钮将打印图像URL的图像。如何打印选定的图像。

回答

1

你正在用src获得精确的图片标签,所以你需要做的只是把它放在页面中的一些HTML中。所以我改变输入框与div现在点击div将填充图像标记。执行

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> 
<script type="text/javascript"> 
$("input:radio[type=radio]").click(function() { 
var value = $(this).val(); 
$('#showoption').html(value); 
    }); 
</script> 

<label>Value</label> 

<div id="showoption"></div> 
+0

太感谢你了 – srikanth

+0

@srikanth很高兴我能帮助 –

+0

当我在电台按钮图像单击显示,但是当我在图片的点击是不显示图像 – srikanth