Hyperlink inside database table???

Is there code to make a text inside a table from a database be a hyperlink?? My idea is to have a list of websites in a table form that constantly updates (this is where the database comes in) and website visitors will click on the link to be taken to the desired site.

I made the database, but I dont know how to make the website link an actual hyperlink… currently its just reading as text since its coming from the database.

Can anyone help?

2 Likes

Hi,

is the hyperlink separated from other text? if so, did you try using url as the db type for the column data?

Shlomi

Hi All. I am trying to acheive the same. I have 4 columns. Firstname, Surname, Suburb, Link. I have added a search to find the persons details in the database and return the results of search in a table. This is working just fine and search results works fine. HOWEVER, the last column LINK, is a Hyperlink to a external web page address, which loads completely seperate information.
How do I make the Link Coloumn a Hyperlink to a specfic External Address?
Also per in the database has a different Hyperlink and it is a fixed address, so it does not change for each person.
I do not know code so just seeking some help with this challenge
Thanks in advance

1 Like

Hi Bruce.

Can you share a link to your website?

Regards,
Genry.

Hi Genry. thanks for reply. not entirely sure what you mean by share a link to my website?
in the table results is a column that has a url web address to a different external Forms workflow website which loads the persons details as part of a existing registration process for events.
all i need the search result to do is find my name, (or anyone who searches) and show the results in the table which includes there url link to go to external web address once they click the column
hope that is clearer.
it does not matter if someone else sees the link during the search as it is not secure or private
thanks and hope for some help

Hey Bruce,

Did you try using repeaters rather than a table to display the results? Can you share the url of the site you are working in? Will be easier to have a look at what you are describing

Shlomi

Hi Shlomi. I am now to coding and I am not sure what Repeaters are at this stage, i will read and learn and maybe that could be a better option. I understand now that it is better to see the page. I have made it live so you can what I mean as per my comments earlier in the thread. Here is link to site.
https://www.ghostfishing.co.nz/search
Hope you can help or offer options of display content so there is a clickable link in the last column, and hopefully I can rename the link so you do not see the entire link
thanks again
Bruce

Sorry by the way, search for Bruce or cody or tawa. These will show some results

Hi Bruce.

I took a look at the structure of your collection. I think changing the ‘Link’ column type from RichText to URL should solve this problem.

Regards,
Genry.

Hi Guys.
I have tried using URL first Genry. I thought that would work and then I read article suggesting using Rich Text and use Link to link off to External Site. I have changed back to URL and sadly it is still now working.
Is using repeaters for text boxes better?

Hi Bruce.

There is an alternative way to perform what you are trying to do.
If you connect the table component to the collection (data-binding) - you can then set the filter of the dataset programmatically according to your search.
You can initialize the dataset filter to return no result at first with some known no result condition.

Using data-binding, URL columns should work as expected.

The reason URL column type does not work using the current implementation on your site, is that there is no notion of URL type column in the raw table representation, if it is not connected to a collection.

Hope this helps.

Regards,
Genry.

Having said that, using the repeaters is giving you more flexible design to your search results.

Regards,
Genry.

Hi Genry
I have just inserted a Repeater and yes it does look good and will provide a little more flexibility for sure
I guess the challenge now is to create the Search for the Repeater???
Again I am not a coder so any help with the search will be greatly appreciated

Bruce,

in your page try the following code instead of binding the text of the link to the url column

$w.onReady(function () {
	 $w("#repeater1").onItemReady( ($w, itemData, index) => {
	   $w("#text20").html = "<a href=" + itemData.hyperlink + ">" +  itemData.name +"</a>";	
	});
});

please let me know if you can make it work. if you need further help with the search, please have a look on this forum for similar threads, or lets please open another new thread

thanks,
Shlomi

Hi Sholmi
Thanks again for your support. I still do not seem to be able to get it to work
The problem is I dont fully understand code as I am learning and a lot of this is over my head
The input search box element is called "input1
Page is linked to Dataset called “MemberLink”
search button is called “search”
Please help me to make this work
Thanks again
https://www.ghostfishing.co.nz/search

Bruce

Bruce,

use this in your code:

import wixData from 'wix-data';

$w.onReady(function () {
	 $w('#repeater1').onItemReady( ($w, itemData, ) => {
	   $w('#link').html= "<a href=" + itemData.hyperlink + " target='_blank' style='text-decoration:underline;'>" +  itemData.name +"</a>";	   
	});
});


export function search_click(event, $w) {
	$w("#dataset1").setFilter( wixData.filter()
	  .contains("name", $w("#input1").value)
	);
}

good luck,
Shlomi

Hi Shlomi,
Nearly there with my problem having read the above. I too need to show a hyperlink in a table that comes from my database. My code looks like this:


and the database looks like this - the ‘link’ field is of type URL.

How can I get it to display as a hotlink, and not like this:


Thanks, Tim

Hi Tim,

I strongly recommend you check out wix code repeaters and look into what Bruce did with his site

Shlomi

Please also check out this thread: https://www.wix.com/code/home/forum/questions-answers/user-input-drop-down-sort

Hi Shlomi,
That’s great, I’ll try and work on code repeaters. I’m a real coding newbie, so just for the moment, how do I get the url in the database to display as a hotlink? Many thanks.