Buy Now
Sign in

Displaying Fields from the DB based on Radio Button Selection

cre8tivemedia , November 03 2018, 16:58
C
cre8tivemedia 92
November 03 2018, 16:58 #381244
I'm using Javascript to get the value of the "id" in the DB from the radio buttons as follows
var a = jQuery("input[name='discount']:checked").val();
document.getElementById("discount_giftcard").innerHTML = a;

var b = jQuery("input[name='portal']:checked").val();
document.getElementById("discount_portal").innerHTML = b;
My HTML has the following
<h4>Discount Gift Cards "id"</h4>
<p id="discount_giftcard"></p>
<h4>Cashback Portal "id"</h4>
<p id="discount_portal"></p>
This works great but I would like to grab other fields from the database based on the radio button selections. DB fields "introtext", "alias" and "urls" Here is a form view -
data-find.png
Can I do this with Javascript or do I need to have another read action to be able to get these fields?
DealGetR.com
healyhatman 7
November 04 2018, 07:30 #381253
Unless you already have that data loaded and somewhere on your form, you'll need to re-read.
Web developer at SkySpider.com.au - I DO NOT work for ChronoEngine!
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
C
cre8tivemedia 92
November 06 2018, 00:13 #381294
Can I do a single read event to get all the fields that I need from the database and then grab them based on the id value of the radio buttons?
or do I need to do separate read events for each field? I just don't know which way is a more efficient way of going about it
DealGetR.com
healyhatman 7
November 06 2018, 03:12 #381303
Just reload the fields and re-read the database, makes more sense than loading all the data every single time and trying to use JQuery to filter it out and rebuild options.
Web developer at SkySpider.com.au - I DO NOT work for ChronoEngine!
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
C
cre8tivemedia 92
November 20 2018, 01:02 #381613
Ok, I've got a read action "read_data15" producing two options for a radio group. I also set up another read action "read_data17" to list different fields from the database as you can see below.
array.png
If I were to select the "id" 9568 from the radio group in "read_data15" how can I display the corresponding "alias" that has the same "id" from the "read_data17"?
Or is there another way to get the "alias" in the first read event "read_data15"? I tried adding additional fields but I'm not sure how to do that with a radio group
Attachments
array.png
array.png
(23.42 KiB)
169 Downloads/Views
array.png
array.png
(31.96 KiB)
208 Downloads/Views
DealGetR.com
healyhatman 7
November 20 2018, 02:50 #381614
Look at the dynamic dropdown demo form.
Web developer at SkySpider.com.au - I DO NOT work for ChronoEngine!
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
C
cre8tivemedia 92
November 20 2018, 22:45 #381653
I've studied the dynamic dropdown demo but I'm getting nowhere... Not sure how this is used for what I'm trying to do
DealGetR.com
healyhatman 7
November 20 2018, 23:02 #381654
The first dropdown should reload the other field, and in the reload event read the database based on {data:first_field}
Web developer at SkySpider.com.au - I DO NOT work for ChronoEngine!
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
healyhatman 7
November 20 2018, 23:48 #381656
Which part of the dynamic dropdown demo are you stuck on? Because it definitely sounds like what you need. You want the user to select an option, and then displays to them an entry from the database based on what they've selected.
Web developer at SkySpider.com.au - I DO NOT work for ChronoEngine!
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
C
cre8tivemedia 92
November 22 2018, 23:52 #381718
That is precisely what I'm trying to do but to a third level... I currently have a dropdown that when selected populates two different radio groups with the correct information.
The dropdown id is "storename" and in the read I am using this for the where condition -
created_by_alias:{data:storename}
This seems to work as intended
What I would like to add is when the user makes a selection from the radio groups I would like to pass the data "introtext", "alias" and various other values from the database to text fields and/or hidden fields to be used for other calculations as well as information displayed to the user.
I tried using a text field but I couldn't figure out how to pass the information so I figured I would try with another radio group since I got that to work before...
I tried adding another radio group but I can only get it to work doing a read event with the dropdown id "storename", this shows the values from both radio groups and obviously won't change when the user makes a radio selection
I would like it to pull from a selection from the radio group with the id "discount"
I tried using another read with the following but had no success -
id:{data:discount}
Here is a front end view using the data from the dropdown "storename" -
DealGetR.com
healyhatman 7
November 22 2018, 23:58 #381719
So when you select an option from the dropdown you want to reload a whole bunch of fields at once? That's a bit more complicated. You might have to wrap them all in a custom div with a set data-reloadurl or make your own Ajax call.
Web developer at SkySpider.com.au - I DO NOT work for ChronoEngine!
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
C
cre8tivemedia 92
November 23 2018, 00:36 #381720
Since I can get the database id from the radio group selection I would like to pull information from the database based on that id. So, when a user makes a selection I can display other details about that selection.
Here is my goal -
A user makes a selection from the dropdown (Store)
which loads radio group options (Discounted Gift Cards) and (Cashback Sites)
the user makes a selection from radio group (Discounted Gift Cards)
I would like to display the discount value which would be the "introtext" field in the database and the article title which would be the "title" field in the database as well as other fields such as the url link to the article and some other information
I have limited knowledge of what you're suggesting, is there somewhere you could point me for information on how I could go about doing this?
DealGetR.com
healyhatman 7
November 23 2018, 00:46 #381721
okay so you want multiple fields from the database displayed as the label of a radio select option?
Web developer at SkySpider.com.au - I DO NOT work for ChronoEngine!
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
C
cre8tivemedia 92
November 23 2018, 01:11 #381722
I'd rather just have certain fields from the database displayed as individual text boxes or hidden fields independent of each other. I was only using a radio select option because I couldn't figure out how to do the text field...
I'd like to be able to display some of the individual fields for the user as well as have some hidden fields that I'll use for background calculations
DealGetR.com
healyhatman 7
November 23 2018, 01:20 #381723
if you don't need to have any of data put into fields you can't have a custom html block with data-reloadurl="{url:reload event}&tvout=view" and the reload event can just output the wrapper div with your data inside it. If you need all those fields populated then sorry but you'll need the wrapper div and a series of {view:field} entries inside.
Web developer at SkySpider.com.au - I DO NOT work for ChronoEngine!
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
C
cre8tivemedia 92
November 23 2018, 02:18 #381724
I don't need the fields populated until the user makes a selection from the radio group. Then, based on the database "id" of the selection I would show the specific fields from the database. Here is an example I mocked up -
example.png
So does that mean I make an html block and put this in it - data-reloadurl="{url:reload event}&tvout=view" then put a reload event in the radio group?
or am I supposed to do something like this in the html -
<div id="wrapper">
{view:}id:{data:discount}
{view:}title:{data:discount}
{view:}introtext:{data:discount}
{view:}id:{data:portal}
{view:}title:{data:portal}
{view:}introtext:{data:portal}
</div>
Attachments
example.png
example.png
(22.62 KiB)
142 Downloads/Views
example.png
example.png
(23.64 KiB)
176 Downloads/Views
DealGetR.com
healyhatman 7
November 23 2018, 02:35 #381725
Do you just need to DISPLAY those fields or do you need to send their data too
Web developer at SkySpider.com.au - I DO NOT work for ChronoEngine!
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
C
cre8tivemedia 92
November 23 2018, 03:01 #381726
Some fields I just want to display but some I want to do math with. I don't think I'll need to send them.
So if a user selects the first selection in Discounted Gift Cards radio group I would display on screen some details about the store
title - A Pea in the Pod
introtext - 25.14
id - 9538
same with second radio group
in the background (hidden fields) I'd do some math. Adding together and multiplying fields and displaying the total on screen
25.14 - introtext (Discounted Gift Cards)
+
4.0 - introtext (Cashback Portal Sites)
+
-- user input
DealGetR.com
healyhatman 7
November 23 2018, 03:11 #381727
So you can use a custom html that you target
<div id="shopinfo" data-reloadurl="{url:event name}&tvout=view"></div>
In the reload event do the read data , then a custom code block containing that wrapper div with all the information you want. Do your calculations with PHP, display the information however you want.
Web developer at SkySpider.com.au - I DO NOT work for ChronoEngine!
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
C
cre8tivemedia 92
November 23 2018, 16:58 #381746
K, I'm pretty sure I don't have the syntax right... Here is what I have -
custom_html.png
radio_group.png
read_data.png
custom_code.png
front end view - link
Attachments
custom_html.png
custom_html.png
(7.44 KiB)
146 Downloads/Views
radio_group.png
radio_group.png
(15.09 KiB)
150 Downloads/Views
read_data.png
read_data.png
(37.07 KiB)
127 Downloads/Views
read_data.png
read_data.png
(37.07 KiB)
152 Downloads/Views
custom_code.png
custom_code.png
(26.73 KiB)
152 Downloads/Views
DealGetR.com