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

11th Oct 2019, 11:16 AM
Svetlana Wilson
Svetlana Wilson - avatar
29 Answers
+ 6
https://code.sololearn.com/WCXFPf646tY8/?ref=app
11th Oct 2019, 2:54 PM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 4
Svetlana Wilson I just built an onChange event trigger function based on your requirement https://code.sololearn.com/W9gxTnV5y1PB/?ref=app
13th Oct 2019, 11:07 AM
Calviղ
Calviղ - avatar
+ 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
11th Oct 2019, 11:54 AM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 3
that is amazing! how can i combine then two codes😰 і am a learner 🙏🙏🙏🙏🙏🙏🙏🙏🙏
11th Oct 2019, 1:13 PM
Svetlana Wilson
Svetlana Wilson - avatar
+ 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 😉
11th Oct 2019, 7:30 PM
Aditya
Aditya - avatar
+ 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 👍
11th Oct 2019, 11:57 AM
Ipang
+ 1
thanks
11th Oct 2019, 12:03 PM
Svetlana Wilson
Svetlana Wilson - avatar
+ 1
Aymen, can you please give an example?
11th Oct 2019, 12:05 PM
Svetlana Wilson
Svetlana Wilson - avatar
+ 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🙏☺️🤞
11th Oct 2019, 3:05 PM
Svetlana Wilson
Svetlana Wilson - avatar
0
It's been a while since I wrote a web page but wait let me try
11th Oct 2019, 12:08 PM
Aymane Boukrouh
Aymane Boukrouh - avatar
0
Do you still need it ?
11th Oct 2019, 12:48 PM
Aymane Boukrouh
Aymane Boukrouh - avatar
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
11th Oct 2019, 1:11 PM
Aymane Boukrouh
Aymane Boukrouh - avatar
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
11th Oct 2019, 1:14 PM
Aymane Boukrouh
Aymane Boukrouh - avatar
0
Aymane, it doesn’work with the original code, i try to tweak it and nothing.....
11th Oct 2019, 1:22 PM
Svetlana Wilson
Svetlana Wilson - avatar
0
Send the tweaked code, it worked perfectly fine on my laptop and on the code playground
11th Oct 2019, 1:23 PM
Aymane Boukrouh
Aymane Boukrouh - avatar
0
how can i share it with you please?
11th Oct 2019, 1:29 PM
Svetlana Wilson
Svetlana Wilson - avatar
0
Write it in code playground, save it, and then post it here
11th Oct 2019, 1:32 PM
Aymane Boukrouh
Aymane Boukrouh - avatar
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
11th Oct 2019, 2:02 PM
Svetlana Wilson
Svetlana Wilson - avatar
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.
11th Oct 2019, 2:11 PM
Aymane Boukrouh
Aymane Boukrouh - avatar
0
I realized that I drote a long code for such a simple script, the solution is actually much easier
11th Oct 2019, 2:18 PM
Aymane Boukrouh
Aymane Boukrouh - avatar