简体   繁体   中英

Insert/show clickable links in/from database from textarea or div

I have a textarea where users can type text, and this text will be insert into the database . Another query show what the user wrote. If an user insert a link, I wanna have a textarea where the link it's clickable and I wanna see the clickable link when I call the query that show the user input.

This is my textarea

<div class="txt-edit-caso-file">
    <div class="et-form-ins">Modified files </div>
    <textarea name="EDITmodifiedfiles" size="9" class="input full-witdh" id="edit-file" value="<?php echo "$file_mod"; ?>"><?php echo "$file_mod"; ?></textarea>
 </div>

If a user write www.google.it I wanna store the link in the database and see it if I call the show query.

I know that a textarea can only have normal text, with no link, html tags etc... So I made an editable DIV that looks like my textarea,

<div name="EDITmodifiedfiles" contentEditable="true" size="9" class="input full-witdh" id="edit-file" value="<?php echo "$file_mod"; ?>"><?php echo "$file_mod"; ?></div>

by the way I don't know how insert datas in the db from a div. because the normal $_POST method seems not to work.

$file_modif = trim($_POST['EDITfilemod']);

So what can I do? Because textarea don't have links, but I can't insert DIV text in the database.

It's not important that the link is stored like a link in the database, I only want to see it as a link when the user see it in the textarea/div , and the user can edit it (the user can insert one or more link, each link in a newline).

Thank you.

........edit I decided to us an hidden textarea (for the input) and a div (for the clickable output). The two boxes thare the same content (If I edit the div, the text go also in the textarea). Now my question is: how can I manage link in the div?

If you want to insert a link into you database via textarea then you have to put that text along with html <a herf="http://www.google.com">Link</a> tag. and when it will display on html page it automatically displays as link.and you can also use the CKEDITOR freely available on internet and use it for textarea to link up your text.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM