Html Form Number Type Unique User Input March 21, 2024 Post a Comment I am using the code below to ask users to rank (prioritize) which sweets they like the best. The users need to rank from 1-3 (1 being the best) Solution 1: <scripttype="text/javascript">functionitem() { cake = Number(document.getElementById('cake').value); twizlers = Number(document.getElementById('twizlers').value); taffy = Number(document.getElementById('taffy').value); if (cake == twizlers) { alert("Some alert cake or twizlers"); returnfalse; } elseif (twizlers == taffy) { alert("Some alert taffy or twizlers"); returnfalse; } elseif (taffy == cake) { alert("Some alert taffy or cake"); returnfalse; } else { returntrue; } } </script>CopyThis will work, otherwise you can use radio button.Solution 2: You can go with a JS check that the user only rank 1 item with a single value and cant rank that item again. You can use JS to do this.Insert an ID for your input field and then document.getElementById("your_id").disabled = false; document.getElementById("your_id").disabled = false; document.getElementById("your_id").disabled = false; var var1 = document.getElementById("your_id"); var1.onchange = function () { if (this.disabled == true) { document.getElementById("your_id").disabled = true; } } CopyThus check this for three items.Baca JugaI Need Jqgrid To Refresh The Entire Page, Not Just The GridRound Just Decimal In JavascriptJavascript Regular Expression To Match X Digits Only Share You may like these postsHow To Choose A Set Of Unique Random Numbers (no Duplicates) Using The JQuery.inArray Method?Removing Duplicate Element In An ArrayShowing Unique Characters In A String Only OnceHow To Remove Duplicated Objects From Javascript Array? Post a Comment for "Html Form Number Type Unique User Input"
Post a Comment for "Html Form Number Type Unique User Input"