I'm trying to create this script where the user can only select one option from category 1, one option from category 2, and the click submit to generate a link.
What would be the best approach if I wanted this to live online and all be done client-side without the need for a server?
Asked
Active
Viewed 71 times
-6

mplungjan
- 169,008
- 28
- 173
- 236

zackheredia
- 1
- 1
-
I'm brand new to this site, but I did upload a picture that I hope explains any questions. – zackheredia Apr 01 '17 at 16:52
-
1Stackoverflow is not a *"how to"* tutorial service – charlietfl Apr 01 '17 at 16:54
-
You should go to the help center and learn [how to ask](http://stackoverflow.com/help/how-to-ask) question on SO – Alon Eitan Apr 01 '17 at 16:54
-
Welcome to SO. A picture is not enough. Please visit the [help] to see what and how to ask. HINT: Post effort and code. For example search google for select unique – mplungjan Apr 01 '17 at 16:54
-
Search for onclick, class, querySelectorAll – mplungjan Apr 01 '17 at 16:56
1 Answers
-1
Use radio buttons
<form>
<fieldset id="group1">
<input type="radio" value="" name="group1">
<input type="radio" value="" name="group1">
</fieldset>
<fieldset id="group2">
<input type="radio" value="" name="group2">
<input type="radio" value="" name="group2">
<input type="radio" value="" name="group2">
</fieldset>
</form>
This answer is from here Multiple radio button groups in one form
If you edit the code a bit you get (You use value1 and value2 as strings for the link)
<form>
<fieldset id="group1" style="float:left;">
<input type="radio" value="" name="group1">
<input type="radio" value="" name="group1">
</fieldset>
<fieldset id="group2" style="float:right;left:100px;">
<input type="radio" value="" name="group2">
<input type="radio" value="" name="group2">
<input type="radio" value="" name="group2">
</fieldset>
<button onclick="myFunction();">Submit</button>
</form>
<script>
function myFunction() {
value1 =document.getElementById('group1').value ;
value2 =document.getElementById('group2').value ;
}
</script>