0
I made a simple script with Jquery that changes some texts in select
of sizes in a store:
<select>
<option value="">Escolha seu tamanho...</option>
<option value="476" price="0" data-label="p">P</option>
<option value="473" price="0" data-label="m">M</option>
<option value="474" price="0" data-label="g">G</option>
<option value="475" price="0" data-label="gg">GG</option>
</select>
$j(function(){
$j('option[data-label="p"]').text('P - 34');
$j('option[data-label="m"]').text('M - 36/38');
$j('option[data-label="g"]').text('G - 40/42');
$j('option[data-label="gg"]').text('GG - 44');
});
But, for example, when I choose the size on select
, kind of the options
update themselves by pulling the child product data.
That is, if I mark "M", it will sort of "refresh the page" (in case update only the select
) and what I put with Jquery will disappear, and come back only when I refresh the page again.
I’m a layman still in Jquery, so I thought I’d create a loop, but kind of think it would slow down the site.
How then could I check if the text is the same as what I want or not, in real time, to always stay what I put? With Ajax would it work? I’m asking because what I still know in Ajax is little, so I have no knowledge.
"With Ajax it would work?" - Yes. Take a look here https://answall.com/a/6634/129 (I really think this other answer solves your problem)
– Sergio
But there the event is done when the element is clicked, would know me explain how it would be without having to click anything?
– Lucas de Carvalho
Lucas
click
is an event, in which case the event would bechange
.– Sergio
Dude... use even Ajax, with shooting. Then you put a GIF loading for the person to realize who is loading.
– Wilson Faustino
Luke your phrase "I mean, if I dial M, it’ll kind of "update the page"" suggests that the page reloads. But a select just by changing the option does not send the page. You can show the code that does this upload?
– Sergio
@Sergio if CAN (only if you can) look at this page and select a size, you will see what I am talking about, he updates the select, bringing the product information son: https://www.livreve.com.br/calca-legging-estampa-amethystet0165
– Lucas de Carvalho
I took a look at the page but I couldn’t find select. Have you solved it?
– Sergio