HTML Form Number Type Unique User Input October 06, 2022 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: <script type="text/javascript"> function item() { 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"); return false; } else if (twizlers == taffy) { alert("Some alert taffy or twizlers"); return false; } else if (taffy == cake) { alert("Some alert taffy or cake"); return false; } else { return true; } } </script> Copy This 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; } } Copy Thus check this for three items.Baca JugaJavascript - Cannot Add 2 Numbers CorrectlyHow Do I Handle Number Input Changes In Jquery?Why Should I Not Use Deprecated Align='right' For Numbers On An Td (table Cell)? Share You may like these postsHtml5 Video Autoplay Not Working In ChromeHow To Display Action Result Of Iframe In Parent WindowSet Width Of Fixed Div Equal To That Of Parent Width (which Is Declared As Percentage)Css Sticky Footer, Header With Scrollable Content Post a Comment for "HTML Form Number Type Unique User Input"
Post a Comment for "HTML Form Number Type Unique User Input"