0
Help with JS very much needed
Good morning! Is there anyone able to help me to add one rule to the following JS: I need to create a JS if statement , so when someone chooses 'XS' size , the 15 size will be appearing in the field, if someone chooses 'S' size, then only 16,17,18,19, ‘M’ -> 20,21,22,23, ‘L’ -> 24-25 will appear in the relevant field and so on. Can someone help here please! Pretty please! https://code.sololearn.com/WWIPkD46frC4/?ref=app
29 Respuestas
+ 6
https://code.sololearn.com/WCXFPf646tY8/?ref=app
+ 4
Svetlana Wilson I just built an onChange event trigger function based on your requirement
https://code.sololearn.com/W9gxTnV5y1PB/?ref=app
+ 3
A better way to do this is to make each groups of sizes in a different div, and then make buttons, when x is clicked, show div with id y, and please write the code in a file so it's easier to read. If you still need help just ask
+ 3
that is amazing! how can i combine then two codes😰 і am a learner 🙏🙏🙏🙏🙏🙏🙏🙏🙏
+ 2
seriously Svetlana Wilson
are you even aware solo learn supports a code playground feature which ensures not to span this q/a thread to unimaginable lengths just paste that code and stare the link here 😉
+ 1
Please save the code and share the link in Description rather than copy-pasting the code there. That way it will be more comfortable for others to review your code and offer suggestions/workaround.
And don't separate 'Java' and 'Script' in Relevant Tags, rather just 'JavaScript', people might misunderstood your question were in relation to Java, a different language that is : )
Good luck with solution 👍
+ 1
thanks
+ 1
Aymen, can you please give an example?
+ 1
hi Aymen, thanks so much, please, don’t think i am rude or ignorant, the script looks awesome, but we have not achieved the goal entirely, how can we restrict the sizes in numbers to show only relevant to the choice: “XS” - > 15 only, “S” -> 16,17,18,19? is it possible to tweak it so it is logical🙏☺️🤞
0
It's been a while since I wrote a web page but wait let me try
0
Do you still need it ?
0
Anyway, I don't know if this is what you really want, but this is what I could do:
https://code.sololearn.com/Wlbb6Kh9rfB6/?ref=app
If you want to display all of sizes, and then let only numbers you need depending on size, just add a new div containing all sizes.
Also there are some modifications you need to do, because it gives error when you click on select size, since it isn't defined, just remove it
0
Don't combine, continue from my code, and add the other sizes, the code I sent it only a demo. if you still need help you can ask
0
Aymane, it doesn’work with the original code, i try to tweak it and nothing.....
0
Send the tweaked code, it worked perfectly fine on my laptop and on the code playground
0
how can i share it with you please?
0
Write it in code playground, save it, and then post it here
0
Ayman, yes, please help🙏☺️
i can continue from your code, it has to be integrated with the product type, product id and product label, but how to add all other fields, which are before the sizes come😰 i feel totally blonde
0
Ok, but it will leave you syntax exactly as it is, tru to make a clearer code next time please, and format it well with spaces and tabs, because this is hard to read.
0
I realized that I drote a long code for such a simple script, the solution is actually much easier