• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: textbox versus radio button

textbox versus radio button 6 months 2 days ago #43057

  • cdg116
  • cdg116's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 4
Hello !

ref.: javascript
To calculate the price of an item I check if the content of a texbox (vervoer) equals a certain value ("levering")

let vervoer = document.getElementById('vervoer').value;
if (vervoer=="levering") {
....
}

This is not working if I replace the textbox with a radiobutton
How is the syntax for using a radio button?

tnx for help
Christian
The administrator has disabled public write access.

textbox versus radio button 5 months 4 weeks ago #43064

  • iceferret
  • iceferret's Avatar
  • OFFLINE
  • Gold Boarder
  • Posts: 216
  • Thank you received: 57
You could try something like this which covers having several radio buttons in a field
function checkRadioSelection(groupName) {
    // Get all radio buttons with the specified name
    const radioButtons = document.getElementsByName(groupName);
 
    // Loop through the radio buttons to find the selected option
    for (let i = 0; i < radioButtons.length; i++) {
        if (radioButtons[i].checked) {
            // Get the value of the selected radio button
            const vervoer = radioButtons[i].value;
 
            if (vervoer === "levering") {
                // Your code for the "levering" case here
                alert("You selected 'Levering'.");
            } else if (vervoer === "otherOption") {
                // Your code for the "otherOption" case here
                alert("You selected 'Other Option'.");
            } else {
                // Handle other cases here
                alert("You selected something else.");
            }
 
            // Exit the loop once a selection is found
            break;
        }
    }
}
call it with
onclick="checkRadioSelection('vervoer');"
If you can keep your head when all about you are losing theirs, then you obviously don't understand the situation!
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!