JSON: How to insert URL in the child node?

I have question with two options. If user select option 1 then I would like to redirect to URL1 and if user select option 2 then I would like to redirect to URL2.

How can I do that?

Please see attached screenshot.

JSON code is here. I am using HTML to show the question.

Question

[
  {
    "question_code": "Q1",
    "type": "radio",
    "question": "Question1",
    "required": "true",
    "options": [
      {
        "code": "Q1OP1",
        "text": "Option1",
        "child": [ ],
        "steps": 11
      },
      {
        "text": "Option2",
        "code": "Q1OP2",
        "child": [ ],
      }
    }
]

Are you using only plain js/html ? How do you generated your radio buttons ? please give other code

I am not sure what exactly I need to give.
But here is the code.

if (que.type == 'radio') {
    radioTypeField(que, name_attr, $question_container);
}
radioTypeField = function (e, name_attr, $container) {
    var $option = $('<div/>', { 'class': settings.option_container });
    $.each(e.options, function (i, op) {
        var child_ids = op.child ? op.child.join(',') : '';
        if (!op.class) { op.class = ''; }
        $('<div/>', { 'class': settings.option_class }).append(
            $('<label/>').html(op.text).prepend(
                $('<input/>', {
                    'name': name_attr,
                    'type': 'radio',
                    'class': settings.option_input_class + ' ' + op.class,
                    'data-code': op.code,
                    'data-child': child_ids,
                    'value': op.text,
                    'data-steps': op.steps,
                    'click': function () {
                        $(this).closest('.' + settings.question_conatiner).removeClass('missing');
                    }
                })
            )
        )
            .append($('<div/>', { 'class': 'option_info' }).html(op.info))
            .appendTo($option);
    });
    $container.append($option);
};

Option input element has value attribute to hold any value connected to that input and name attribute to group different inputs. When you have it you can access value like so:

document.querySelector('input[name=input_group_name]:checked').value;

Then your submit handler can redirect window to the url that will be stored as a value

In case of jQuery I guess it would be something like that:

$('input[name=input_group_name]:checked').val();

Thank you very much for your response and sorry for the late reply.

It didn’t work for me as I am creating radio button using the JSON.

Thanks again.

What do you mean by you’re creating it with JSON? This is same question as @MathisBarre. JSON is a text format used to pass data around – eg you request some data over a network, you get it in JSON format, you decode that to JavaScript, then you have a JavaScript object and that’s the thing you work with. You can’t use that JSON object directly, for you to be using it it must be a JavaScript object, not a text string, and in which case you can just use normal JS methods to push values into the array.