【问题标题】:How to get the value of the image when clickin点击时如何获取图片的值
【发布时间】:2019-05-11 17:18:03
【问题描述】:

如何在$_POST 上为我们获取图像的价值

$url_f = $crawler->filter('#content .galleries_overview .item')->each(function(crawler $node, $i) {
 //echo $node->html();
    $image = $node->filter('img')->attr('src');
    $src = $node->filter('a')->attr('href');
    $href = 'https://example.com/'. $src;
?>
<input type="image" name="submit_blue" value="<?php echo $href ?>" src="<?php echo $image ?>">

<?php

 }); 

?>

【问题讨论】:

    标签: javascript php input


    【解决方案1】:

    你可以使用 onclick

    <input type="image" onclick="sendme('<?php echo $href ?>')" src="<?php echo $image ?>">
    

    并将其添加到您的页面:

    <form method="post" id="myform">
    <input type="hidden" name="submit_blue" id="submit_blue" value="" >
    </form>
    <script>
    function sendme(x) {
        document.getElementById("submit_blue").value = x;
        document.getElementById("myform").submit();
    }
    </script>
    

    如果我不想使用 jquery 或其他东西,那是我使用的 javascript 解决方案

    顺便说一句,我不喜欢使用 URL 作为值

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-04-14
      • 2015-09-06
      • 1970-01-01
      • 2010-09-06
      • 2017-11-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多