# Getting Radio buttons value with Prototype.js

In Prototype.js, there’s a handy function \$F to get the value of a form element.
However it doesn’t work well with a group radio buttons. The argument of \$F is the id of the element, and since id is unique, we can’t use the name of the radio group to get the value, which is essentially how the server side gets the value.

``````
<form name="myform">
</form>

#wrong
var typeValue = \$F('type');
```
```

Here’s a quick solution.

``````
```
```

# Hash recursive merge in Ruby

For multi-dimension Hash, .merge will replace the values as a 2 dimension hash.

``````
>> {"number" => {"1" => "one","2" => "two"}}.merge({"number" => {"3" => "three"}})
=> {"number"=>{"3"=>"three"}}
```
```

We needed the keep the hash values and merge complex hash together that is loaded from YAML.

Solution?

``````
class Hash
def recursive_merge(h)
self.merge!(h) {|key, _old, _new| if _old.class == Hash then _old.recursive_merge(_new) else _new end  }
end
end

>>{"number" => {"1" => "one","2" => "two"}}.recursive_merge({"number" => {"3" => "three"}})
=> {"number"=>{"1"=>"one", "2"=>"two", "3"=>"three"}}

```
```
{"ft_lang_label":"__label__en","ft_lang_prob":0.5578565,"math_prob":0.9778161,"size":662,"snap":"2019-43-2019-47","text_gpt3_token_len":170,"char_repetition_ratio":0.13525836,"word_repetition_ratio":0.0,"special_character_ratio":0.2779456,"punctuation_ratio":0.13432837,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9940388,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-11-13T14:56:18Z\",\"WARC-Record-ID\":\"<urn:uuid:7005aa19-d369-44be-b0fe-9abb3bf2a248>\",\"Content-Length\":\"39246\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:e6e20f56-a814-4418-9c69-caa5a85a914b>\",\"WARC-Concurrent-To\":\"<urn:uuid:82f8287b-8833-43f1-816b-1ad8d259edf0>\",\"WARC-IP-Address\":\"192.0.78.25\",\"WARC-Target-URI\":\"https://rexchung.com/2007/02/\",\"WARC-Payload-Digest\":\"sha1:LR3I6DZ6ALMYVMPWMMPESQUCTUJ5VFZ7\",\"WARC-Block-Digest\":\"sha1:P3STCUI3DLQZHO2OU42JSSBD3IIKEOP3\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-47/CC-MAIN-2019-47_segments_1573496667262.54_warc_CC-MAIN-20191113140725-20191113164725-00187.warc.gz\"}"}