使用输入字段更新图像src


Update image src with input field.?

三个url输入字段。

<input type="url" name="image1"/>
<input type="url" name="image2"/>
<input type="url" name="image3"/>

和三个图像标签。

<img src="Image link from first input"/>
<img src="Image link from second input"/>
<img src="Image link from third input"/>

我可以用php做这件事吗。?使用一些条件,例如,如果我只想更改一个图像src,而不是其他src代码不更改,我的意思是只更新一个图像。

简单的方法:

<img src="Image link from first input"/>

成为

<img src="<php echo $_GET['image1']]?>"/>

假设您的表单使用get

表单页面:

<form method="post" action="actionthingy.php">
    <input type="text" name="image1"/>
    <input type="text" name="image2"/>
    <input type="text" name="image3"/>
</form>

actionthing.php:

<?php
echo '<img src="'.$_POST['image1'].'"/>';
echo '<img src="'.$_POST['image2'].'"/>';
echo '<img src="'.$_POST['image3'].'"/>';
?>