Possible to preselect a default answer in a Multiple Choice Single Response (Radio) survey question?

Options

Is it possible to preselect a default answer in a Multiple Choice Single Response (Radio) survey question?

Tagged:

Comments

  • Hey Jill,

    There is no way to do it within the survey tool, but see my answer here . Basically you can copy the code and then manipulate the form a little more to one's liking.

    Alternately, you could add a little JS to the pagebuilder page to do the trick for you:

    here's some example HTML (two sets of radio buttons)



    <span class="Explicit"><label class="wrapable" for="1777_5021_2_21780">my choices</label></span><br />
    <span class="NetscapeFix">
    <input type="radio" name="1777_5021_2_21780" id="1777_5021_2_21780_1" class="radio" value="choice one"
    /><span class="Explicit"><label class="wrapable" for="1777_5021_2_21780_1">choice one</label></span><br />
    <input type="radio" name="1777_5021_2_21780" id="1777_5021_2_21780_2" class="radio" value="choice two"
    /><span class="Explicit"><label class="wrapable" for="1777_5021_2_21780_2">choice two</label></span><br />
    <input type="radio" name="1777_5021_2_21780" id="1777_5021_2_21780_3" class="radio" value="choice three"
    /><span class="Explicit"><label class="wrapable" for="1777_5021_2_21780_3">choice three</label></span><br />

    <span class="Explicit"><label class="wrapable" for="1777_5021_2_21781">my choices</label></span><br />
    <span class="NetscapeFix">
    <input type="radio" name="1777_5021_2_21781" id="1777_5021_2_21781_1" class="radio" value="choice one"
    /><span class="Explicit"><label class="wrapable" for="1777_5021_2_21781_1">choice one</label></span><br />
    <input type="radio" name="1777_5021_2_21781" id="1777_5021_2_21781_2" class="radio" value="choice two"
    /><span class="Explicit"><label class="wrapable" for="1777_5021_2_21781_2">choice two</label></span><br />
    <input type="radio" name="1777_5021_2_21781" id="1777_5021_2_21781_3" class="radio" value="choice three"
    /><span class="Explicit"><label class="wrapable" for="1777_5021_2_21781_3">choice three</label></span><br />

    Here's the Javascript... Notice in the HTML that the Name of the radio button is general (the radio button set shares the name) but the ID is specific. So we can just run through an array of specific ID's and make those radio buttons selected. (if you only have 1 question, you don't really need an array, but if you want to keep the code general... If the first item was going to always be selected, then you could probably make this even more general (run through all input fields looking for radio buttons, select the first item of radio buttons with a given name))

    <script>

    //this is the NAME of the radio button's input tag

    var selectedAnswers = new Array()

    selectedAnswers = "1777_5021_2_21780_3"

    selectedAnswers = "1777_5021_2_21781_2"

    // our function to do the work

    function makeSelections() {

    var radiobutton

    for (var x = 0; x < selectedAnswers.length; x++ ) {

    radiobutton = document.getElementById(selectedAnswers)

    if (radiobutton!=null) {

    radiobutton.checked = "checked"

    } else {

    alert("INPUT box with the name" +  selectedAnswers + " does not exist")

    }

    }

    }

    // call the function. The code above could be anywhere, but this would need to be called after the form is loaded.

    makeSelections();

    </script>

Categories