SOLVED: Link Checkbox to Database Field

I have a Database called "ReviewLinks"and a Dynamic Page that links to this database.
On the Dynamic Page I have separate check boxes where only one box can be selected by the


logged in user. Once selected, I would like the ReviewLink that was selected showing in Review Link 1 box. I cannot get code working to do this. Any suggestions to help with this?

Yes. Show us the code, that works a lot better. ALso, if you use checkboxes but only 1 can be selected, the accepted user interface model for this is using radio buttons.

Hi Giri, I am now changing to radio buttons and will send you code as soon as I complete. Bill

Hi Giri, Her is how far I got with the code:

You can get the index of the selection in the RadioButtonGroup with just one line. Something like this:

let selectedIndex = $w(“#radioGroup”).selectedIndex;

You can then use selectedIndex to decide what to display. However, your code is checking for the user’s selection, but isn’t displaying anything. You can use wix-location.to() to go to the appropriate link.

Hi Yisreal,
Thank you for the one-liner for the radio buttons. This is the first time I have used radio buttons.

On the second part and where I am having trouble, I am on a dynamic page that picks up the Company Name from a Database of over 10,000 Companies. Then based on the company name, I need to select the review site link (URL) for that Company based upon the radio button selected.

Can you guide me on how to approach this?

Hi Bill, sorry I missed a day. Had a lot of things to do. But I saw @yisrael-wix stepped in to help you with the radio buttons. Now, for your next trick, getting the URL, you will have to tell us a bit more about your database setup. LIke, how you setuo the Reviews collection and the Companies collection. Without that, we´re stearing kinda blind. Could you post that?

Hi Giri

I really appreciate yours and Yisrael’s help. I use the Title field as the key field as it is the Company Name.
On the Dynamic page, I have the “CompaniesNEW” database as the dynamicDataset and the “ReviewLinks” database as dataset1.I have the two databases filtered by title.

The “ReviewLinks” Database has the following fields:
Title (Company Name) - Field Key - title (text)
BBB Review Link - bbbReviewLink (URL)
DonePronto Review Link - doneProntoReviewLink (URL)
FaceBook Review Links - faceBookReviewLinks (URL)
Feedback Review Link - feedbackReviewLink (URL)
Google Review Link - googleReviewLink (URL)

The “CompaniesNEW” Database has some of the following fields:

Please let me know if you need more.
Kindest Regards, Bill

Hi Giri,
I forgot to mention, you can see I then SMS message the link as part of my SMS to Customer.
Bill

BIll, I think I am starting to understand what you want:

  1. companiesNEW holds basic company info about Reviewers (donepronto, but also Google?)
  2. reviewlinks holds reviews about a certain product, PER COMPANY and has URL´s to them

You want to display reviews PER PRODUCT/PER COMPANY.

Can you confirm?

It´s always hard for outsiders to get an understanding of what other people are trying to achieve. Sometimes it´s not a coding problem, but a DB setup problem. And to be able to help, you first need to understand what someone is trying to achieve.

Hi Giri,

I think I did not explain well. CompaniesNEW has the complete information on each Company except the URLs for the review sites. The review Links are located in the reviewLinks database. The reviewLinks database has all review sites the Company is on and authorized by Company. Both Databases are link by Company Name (title).

I would like to move the review link selected to reviewLink21 text box.

Kindest Regards,
Bill

That I got. But the Reviews, are they about the Company, or about a Product (Euro Windows, Trees Hardwood Flooring)? Don´t want to pester you, but it´s important to be able to answer question.

Hi Giri,
The Reviews are about the Company.
Kindest Regards,
Bill

Hi Giri and Yisrael, Solved my problem.

export function radioGroup1_click(event,$w) {
let radioBtn = $w(“#radioGroup1”).selectedIndex;

	if(radioBtn === 0) 
	{ 
	$w("#reviewLink1").value = $w("#input1").value;	 
	} 
	if(radioBtn === 1) 
	{ 
	$w("#reviewLink1").value = $w("#input2").value; 
	} 
	if(radioBtn === 2) 
	{ 
	$w("#reviewLink1").value = $w("#input3").value; 
	} 
	if(radioBtn === 3) 
	{ 
	$w("#reviewLink1").value = $w("#input4").value; 
	} 
	if(radioBtn === 4) 
	{ 
	$w("#reviewLink1").value = $w("#input5").value; 
	} 
	if(radioBtn === 5) 
	{ 
	$w("#reviewLink1").value = $w("#input6").value; 
	} 
	if(radioBtn === 6) 
	{ 
	$w("#reviewLink1").value = $w("#input7").value; 
	} 
	if(radioBtn === 7) 
	{ 
	$w("#reviewLink1").value = $w("#input8").value; 
	} 

}

Thank you for helping me think correctly.
Kindest Regards,
Bill

Bill, glad you worked it out.

Nice - glad you worked this out. The if statements allow flexibility, but if all you want is to set #reviewLink1, then you might try something like this:

let id = '#input' + (radioBtn + 1);
$w('#reviewLink1').value = $w(id).value;