Ruby
Ruby

Reputation: 153

Can radio buttons be selected through tabs?

I created an options page with some tabs: https://www.sandiegouniontribune.com/subscriptions/BA/?p=02. How can I make it so that when a user selects a day, the radio button is already selected for the user?

Tabs are just in a ul list and inputs are in a div.

Upvotes: 0

Views: 407

Answers (2)

wi_marti
wi_marti

Reputation: 54

Load a JS function to catch the tab being activated which will "check" the radio button when it becomes active. Below will auto-check radioButton1 when tabs-1 is clicked:

$( "#tabs-1" ).on( "tabsbeforeload", function(event) {
        document.getElementById("radioButton1").checked = true;
} )

Upvotes: 0

Anurag Verma
Anurag Verma

Reputation: 495

Use a checked attribute to check the radio buttons by default.

<input type="radio" name="price" value="" checked="checked" />

Upvotes: 1

Related Questions