0

In my work,I have to face some situations that I have to select some specific input radio, like familiar or strangers, I usually select strangers. If there any ideas to auto select [strangers] ?

I press F12 to use console to active these code:

document.getElementsByClassName('ant-radio-input')[1].checked = true

but the html displays not selected.

yunzen
  • 32,854
  • 11
  • 73
  • 106
  • 1
    https://stackoverflow.com/questions/4711036/assign-an-initial-value-to-radio-button-as-checked – Enzy Apr 15 '19 at 07:11
  • Possible duplicate of [Assign an initial value to radio button as checked](https://stackoverflow.com/questions/4711036/assign-an-initial-value-to-radio-button-as-checked) – Core972 Apr 15 '19 at 07:12
  • use checked = "checked" for the value you want to be checked initially – Syed Mehtab Hassan Apr 15 '19 at 07:14
  • What do you want to achieve? Is this your code you are trying to change, or are you using other sites' service and want to automate the filling out of forms? – yunzen Apr 15 '19 at 07:16

3 Answers3

0

There are some Chrome plugins you can use for automating tasks like these and make your life easier.

So essentially, save your script in one of these plugins and whenever you open that website again it will be pre-selected.

Slyper
  • 896
  • 2
  • 15
  • 32
0

Just use this in your input code: input type="radio" name="strangers" value="" checked="checked"

lucky
  • 308
  • 2
  • 4
  • 17
0

You could add a bookmark in your browser with the JS code. This should be prefixed with javascript:

So add this URL to your bookmarks

javascript:document.getElementsByClassName('ant-radio-input')[1].checked = true:

yunzen
  • 32,854
  • 11
  • 73
  • 106