Prevent default behavior when a radio button is clicked

I have a form with two radio buttons, and I want to prevent either of them from being checked. Disabling them is not an option because I still need the selected value to be submitted to the database. When one button is clicked, it gets checked but then doesn't allow me to click the other one. I want both buttons to remain unchecked.

 <form action="here.php" method="post"> 
    <input onclick="return false" type="radio"  name="firstone" value="Yes" /> Yes 
    <input  onclick="return false" type="radio" name="firstone" value="No" /> No
    <input type="submit" /> 
    </form>

Does anyone have a solution for this without using Javascript?

Answer №1

Instead of focusing on avoiding clicking on radio buttons, consider utilizing a hidden element to store the values that you want to submit along with your form.

Answer №2

One possible explanation for your desire to deactivate them without using the term 'disabled' may be due to their unattractive appearance when in that state.

Have you considered modifying the CSS on the respective page instead?

:disabled CSS selector reference

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The jQuery method .find() is unable to locate the <option> tag and behavior unpredictably

Currently, I am working on a webpage that features a table with filtering capabilities using jQuery. The filtering functionality is achieved through a Bootstrap 4 dropdown menu where each option is assigned a specific value: <select id="inputState& ...

Unable to trigger AJAX POST with jQuery click handler

Important Note: Personally, I have a preference for utilizing jQuery over the shorthand $; although it involves more typing, I find it to be more readable. I am working on a simple form that allows users to input their first and last names as well as an e ...

Preventing distortion of the object when using camera.lookat() in three.js

I have created a piece of code that moves an object randomly on the screen using camera.lookat(). However, I noticed that when the object moves to the sides of the screen, it slightly changes its shape to look at the camera, causing a skewing effect. I wa ...

Exploring ways to provide choices in date and time selection within Rails applications

I need to update a form to allow users to select a time duration using predefined options. Previously, I was using a basic date selector but now I need to change the functionality. <%= f.datetime_select :ends_at, :start_year => Date.current.year %&g ...

Is there a way to securely embed YouTube videos in my web application without exposing the direct video links?

I'm hoping to integrate YouTube videos into my web application, but I need a way to prevent users from accessing the direct video links while they are using the app. Does anyone have any suggestions on how this can be accomplished? I am unsure of how ...

Upon completing the upload, dropzone.js displays checkmark and x icons for confirmation

It seems like there may be a CSS problem. When I programmatically create a dropzone box, I notice that the checkmark and x icons, along with other text, appear after the upload (see image link). <div id="header-dropzone"></div> $("#header-drop ...

The attempt at performing an inline edit in react.js was unsuccessful when trying to open a

After clicking on edit, I expected only 1 row to be affected. However, all rows were impacted. What mistake have I made? .. renderItem(){ return( this.state.items.map((item,i)=> <li key={i}> {this.state.isEdit ? this.renderEd ...

Sliding in content from the right using Jquery

Looking for a way to bring in a box from the right by either sliding or bumping it? Any ideas on how to accomplish this? Here's the current code I'm utilizing: $(window).load(function(){ setTimeout(function(){ $('.popin-window& ...

Interact with HTML style attribute using JavaScript

Is there a way to retrieve a specific CSS property from the style attribute of an HTML element, without considering the stylesheet or computed properties? For example: <div style="float:right"></div> function fetchStyleValue(element, propert ...

Is it possible to integrate a PDF file into a webpage while also preventing users from downloading it?

I need help with a website that has various PDFs available for users to view. However, we want to prevent users from downloading these PDFs. Ideally, I'm looking for a solution using JavaScript/HTML. We've attempted different methods to disable ...

A guide to retrieving all keys from a JSON object in Javascript

{"data": {"characters":[ {"name":["Harry Potter"],"age":["18"],"gender":["Male"]}, {"name":["Hermione Granger"],"age":["18"],"gender":["Female"]} ]} } In the given JSON data, I am interested in retrieving the keys like name, age, gender for ea ...

Retrieve posts from Angularjs

I am attempting to fetch tweets from a Twitter account using only AngularJS without the use of PHP or any other programming language. I have made several attempts but have not been successful. Additionally, I must utilize the 1.1 version of the Twitter A ...

The Rx min.js file was nowhere to be found in the "node_modules xjsundles" directory even after running npm install rxjs

As I was integrating the component RxJS into my project, I ran the command npm install rxjs. However, upon checking the node_modules/bundles file, I noticed that there is no Rx.min.js present. Instead, I found rxjs.umd.js and rxjs.umd.min.js files. I am c ...

I am experiencing a problem where my webpage does not load properly when trying to access it

After setting up a route triggered by a specific click event using AJAX, I noticed that although my route is being called, the page content is not rendered as expected. Here is my AJAX function: function showProfile(user_id) { console.log("show pro:" + u ...

IE compatibility with CSS2 selectors

Is there a plugin, preferably jQuery, that can enable the use of CSS2 selectors like 'parent > child' and 'element:first-child' in my stylesheet for IE6, which doesn't seem to support them natively? ...

How can I determine the size of the custom options dropdown in Magento?

I'm facing a challenging issue that I can't seem to crack. It might be because I'm still learning the ropes and struggling with technical jargon. Please bear with me as I try to explain my problem. Here is a summary of what I'm trying ...

Error encountered while trying to eliminate array element

I have a project in the works that involves creating a page where users can filter suggestions and vote for their favorites. The screen is divided into 3 tabs: [Top Rated], [Newest], and [My Votes]. Upon loading the screen, a call to the database is made ...

Tips for distinguishing between local and remote variables (PHPStorm, Webstorm)

Is there a way to create a dynamic variable within my project that can be accessed in both JavaScript and PHP, which will automatically populate based on settings in WebStorm before deployment (locally or remotely)? For instance, let's say I define th ...

The PrimeReact components are not displaying the PrimeReact theme properly

I'm currently working on integrating a Menubar component from PrimeReact into my React application. I tried to apply one of the predefined PrimeReact themes by importing it, but the page ended up looking strange. When I imported "./../../node_modules ...

Navigate the Angular interceptor route to display a 404 error page when clicking on a `<a href="#">` tag

When using href="#" as a placeholder in html, I encountered an issue where Angular was unable to recognize it and would route to the 404 page despite having the following configuration in the module. How can this problem be resolved? .config( function m ...