drudfe0446838 2016-05-23 11:49 采纳率: 0%
浏览 49
已采纳

如何在php中获取和打印页面中的图像

I want to print the image within the page. here is my code

<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>     
<input type="text" id="showoption" name="name" disabled="disabled">   
</label>

When I click on selected radio button the image it prints the image url. how to print the selected image.

</div>
  • 写回答

1条回答 默认 最新

  • duanjie5570 2016-05-23 11:54
    关注

    You are getting exact image tag with src so what you need to do is just put it in some HTML in page. So i change the input box with div and now on click the div will be fill with Image tag.

    <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>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?