Submitted by viking on 2022/12/03 15:08

I pasted the following link as html in the URL field

CNN  ( it has the HTML code: <A href="https://us.cnn.com/">CNN</A> )
Clicking the link in the URL field works fine.

I used my Function, posted elsewhere, to modify my Item so that it looks like this:
My Item (Link)

and as HTML:
My Item <a href=[url]>(Link)</a>

Clicking on the Link doesn't work.
I guess that it doesn't work because "<A href="https://us.cnn.com/">CNN</A>" is not a URL
It only works if I paste "https://us.cnn.com" in the URL field

Is there some easy way to fix this, or do I need a Function to parse out the URL "https://us.cnn.com" from the pasted link, and then modify my Item:
My Item <a href="https://us.cnn.com">(Link)</a>?
 

p.s The reason that I want to paste the link rather than the URL is so that I can create a Function which makes my Item:
CNN (Link). The Link would actually be pasted in the URL field of Forms.

Comments

Yes, but then I will not be able to create an Item like in the p.s.:  CNN (Link).

I think that the only way is to create a function that parses out the URL and CNN from the copied HTML Link:
"<A href="https://us.cnn.com/">CNN</A>"

EDIT: Never mind, I just found out that I can not paste the complete link ("<A href="https://us.cnn.com/">CNN</A>") by pasting it in the URL field of a Form. It only pastes as text. Thus, my approach above will not work for Forms (it may still work if I paste it in a Grid).

I will need to copy/paste it twice in the Form:
First copy/paste "CNN" as an Item.
Then copy/paste paste the URL into the URL field.
My previous function (http://infoqubeim.com/drupal5/node/5668) will then convert the Item to "CNN (Link)"

If anyone is interested, I have the solution.
I added a Firefox extension (e.g. https://github.com/nhoyt/copy-page-link  or https://github.com/asamuzaK/url2clipboard ) which copies a webpage hyperlink as "Title URL". For example, "CNN  https://us.cnn.com".

I next created a text field TitleURL and added it to my IQ Form.

I next put this equation in the TitleURL field:
AME:[Item]=ItemwLink([TitleURL])

And created this function:

Function ItemwLink(TitleURL)
    Itemlength=Len(TitleURL)
    HTTPPosition=Instr(TitleURL,"http")
    Title=Left(TitleURL,HTTPPosition-2)
    URL=Right(TitleURL,Itemlength-HTTPPosition+1)
    Item=Title & "  " & "<a href="&URL&">(Link)</a>"
   ItemwLink=Item
end Function

In the Text field TitleURL, find the webpage Title and URL & create an Item "Title (Link)", where Link is the hyperlink.
If "http" does not exist in TitleURL, do nothing.
If TitleURL is changed to a different Title+URL, change the Item.

I can now paste the hyperlink copied from Firefox into my Form and an item is created:
CNN (Link)

Note that it is not possible to directly add hyperlinks to Forms, but this solution fixes this. Furthermore, I like CNN (Link) better than  CNN because when I edit the item, I don't accidentally go to the webpage.

How do I ?