0
I’m putting together a table of plans TABLE , where the "STICK TO THE PLAN" button changes link according to the options chosen from select us.
Two of the 4 select user should select, are STATE and CITY, these, not written in select option and yes are pulled from a database.
Therefore, in order for the join button to change links according to the selected options, you needed to know the value of each select option, which are pulled from the database.
Therefore, I would like to know if it is possible to discover the value of a select that is pulled from the database, or if there is some other way to mention the city, or state without being by value, which in that case does not exist.
Thank you.
jQuery(function($){
$('#volume, #tipo, #estados').change(function(){
var volume = $('#volume').val();
var tipo = $('#tipo').val();
var estados = $(this).val();
if (volume == "peq" && tipo == "visitas_quatro" && estados == "SP") {
$('.Linkbotao').attr('href', 'site.com');
The Example I made below is exactly for this
– Rafael Augusto
Right, except in my case for every combination of city and state with the other options it would generate a link. For example: Estado (SP,) Cidade (São Paulo), Volume (50), Visitas (4) is a link. Already State (SC), City (Florianópolis), Volume (100), Visits (8) is another link. And so on. How will I set a link for each city with the code you posted below? At the moment I am doing so: if (volume == "peq" && type == "visitas_four" && states == "?" && cities == "?") { $('.Linkbotao'). attr('href','http://site.com'); where have "?" would be the value of every sick option and city
– Eduardo Marotti
is doing the right way, is not working?
– Rafael Augusto
I haven’t tested it with the code you sent me. Since I don’t have much intimacy with the subject (js), I don’t know what information of the code you gave me to put there where the "?" , where would be the value. You know me to tell?
– Eduardo Marotti
I’m gonna ride, baby
– Rafael Augusto
I edited the city code, take a look
– Rafael Augusto
Dude, I edited my question there and put my code so far. (Only the part that changes the button link) I’m racking my brain trying to understand this code you posted, but I can’t get it to fit my code. Can you not take this code that I posted as a base and give me an example on top of it of how it would be with the state SP selected and city São Paulo, for example. I saw that in your code there is something with the country, already in my table would be only the state and city even. Anyway I appreciate the attention you’ve given me. I’m almost there.
– Eduardo Marotti
See if it gets better now, I updated.
– Rafael Augusto
Dude, it’s still a little complicated for me, sorry rsrs. I need to add that city, Function and state? To half lost there with the country in the middle, in my case would be only state and city, which are pulled from the bank, already the type and volume are listed in select, in the code itself. And where would I indicate the state and city for a link, for example that of são paulo - sp? If you can take a look at the table’s source code, you can see how I’m doing so far. The link is: https://piscinafacil.com.br/tabela_teste2.html
– Eduardo Marotti
The country Voce can take off, ignore it, focus only on the last city, where I gave the example
– Rafael Augusto
It is the buttons JOIN that Voce wants to change?
– Rafael Augusto
That’s right, it’s the JOIN button link. It would change depending on the combination of options that is selected in the Selects. Each combination is a price(plan) and each price is a link to membership. You may notice that when selecting a given city the price varies, however when we develop the table, we forget that the button link would vary. I still haven’t been able to adapt this code to my code
– Eduardo Marotti
https://jsbin.com/dokosiq/edit?html,js,output
– Rafael Augusto
I tried using this code there, replacing select with '#states' which is the select name of the state part. However, when I added the code the state select is no longer showing any state.
– Eduardo Marotti
Probably because you didn’t implement it correctly
– Rafael Augusto
Did you use Let or var? if it was Let, use var (by guarantee), from any error? I saw your code from the link you gave me, and that’s exactly what I said
– Rafael Augusto
I tried both, Let and var. I edited my question there and put the code as it is at the moment. I joined the volume and type state part, because the link will change according to all options: volume, type, state, and city (which is not in the code yet). Now, as it is there, it is showing the list of states, however, when I select the options that are described there in the code (state:SP volume:50 and visits:4) the link is not changing. What I’m doing wrong. If you prefer you can look right at the page code: https://piscinafacil.com.br/tabela_teste2.html
– Eduardo Marotti