-1

The HTML code I provided works in an online HTML editor, but as soon as I use it on my SharePoint site it deletes the Checked="Checked" that's pre-selecting the radio button. What is going on? Anything helps, thanks.

        <input class="carousel-open" type="radio" id="carousel-1" name="carousel" aria-hidden="true" checked="checked">
David Kris
  • 799
  • 2
  • 10
  • 25

2 Answers2

0

Here you go:

<input type="radio" name="r" id="id2" value="2" /> <label for="id2">not selected</label><br>

<input type="radio" name="r" id="id1" value="1" checked /> <label for="id1">already selected</label><br>
    
Iłya Bursov
  • 23,342
  • 4
  • 33
  • 57
0

How can I make my radio button automatically selected when the page loads?

1) You haven't implemented the checked attribute.

2) Remove the hidden attribute that you currently have, otherwise, the radio buttons won't be visible.

<input name="carousel" class="carousel-open" id="carousel-1" aria-hidden="true" type="radio"  checked="checked" />

<input name="carousel" class="carousel-open" id="carousel-2" aria-hidden="true" type="radio"   />

Relevant Reading:

What's the difference between HTML 'hidden' and 'aria-hidden' attributes?

HTML checked Attribute

Community
  • 1
  • 1
Ousmane D.
  • 54,915
  • 8
  • 91
  • 126
  • @ColeGwozdecki because you've got the hidden attribute on hence you cant see it – Ousmane D. Mar 21 '17 at 20:38
  • @ColeGwozdecki remove the hidden attribute – Ousmane D. Mar 21 '17 at 20:39
  • why not see the snippet i have provided? and if it doesn't work then update your question and i will look at your full markup. – Ousmane D. Mar 21 '17 at 20:43
  • @ColeGwozdecki can you please update your post with your full markup?, the solution i have provided obviously works because the snippet proves it and like i said please update your post with your full markup. – Ousmane D. Mar 21 '17 at 20:46
  • When I create this is on an online HTML editor, using Checked="Checked" works but when I use that code on my SharePoint page it removes the Checked="Checked" like its saying its not valid HTML code to use. – David Kris Mar 21 '17 at 20:54
  • It works in the HTML editor, but again when I use that code on my SharePoint page it removes the Checked="Checked" – David Kris Mar 21 '17 at 20:57