0

enter image description hereI have this HTML markup for the Radio Button, I am facing awkward issue in this break issue,

<div class='selectorField draggableField radiogroup'>
    <label class="control-label" style="vertical-align: top">Radio buttons</label>
    <div style="display: inline-block;" class="ctrl-radiogroup">
        <label class="radio">
            <input type="radio" name="radioField" value="option1">Option 1</input>
        </label>
        <label class="radio">
            <input type="radio" name="radioField" value="option2">Option 2</input>
        </label>
        <label class="radio">
            <input type="radio" name="radioField" value="option3">Option 3</input>
        </label>
    </div>
</div>

Here is also jquery part that is responsible for loading the values:

load_values.radiogroup = function (ctrl_type, ctrl_id) {
    var form = $("#theForm");
    var div_ctrl = $("#" + ctrl_id);
    var options = '';
    var ctrls = div_ctrl.find("div").find("label");
    var radios = div_ctrl.find("div").find("input");

    ctrls.each(function (i, o) {
        options += $(o).text() + '\n';
    });

    form.find("[name=name]").val(radios[0].name);
    form.find("[name=options]").val($.trim(options));
}

I am showing you the image that show how the radio buttons are getting rendered.

enter image description here

I need to delete the space between the Option1 Option2. It works fine if I never format the code.

Jot Dhaliwal
  • 1,470
  • 4
  • 26
  • 47

1 Answers1

1

I'm not sure why you are trying to add options like that but this is how i would fill in the select element:

ctrls.each(function (i, o) {
        options += "<option value='"+$(o).text()+"'>" + $(o).text() + "</option>";
});

form.find("select").html(options);

I'm not sure of this last step. If your select has an id as:

<select id="selectId></select>

then you could replace my last line with this:

$("#selectID").html(options);
nowhere
  • 1,558
  • 1
  • 12
  • 31