Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Prevent rendering image inside input field

I have normal text input like this

<input type="text" id="pixel_url_<?php echo $link_id;?>" value="<?php echo $pixel_url;?>" class="form-control" placeholder="Link URL">

I am looking to display img code inside input value so my users can see it and copy it. like below image

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

But my code is showing output like below image

enter image description here

my value is like below

<img src="https://example.com/pixel/action?link=25&att=2&ref=" width="1" height="1">

I am not getting idea how I can prevent image rendering and show it in input value.

Thanks!

>Solution :

The reason it is not working is that the quotes besides the value attribute are double quotes, also the quotes in your img element are double. You either need to escape the quotes of the img element or alternate the quotes of the value attribute or img element.

Try this:

value='<?php echo $pixel_url;?>'
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading