Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q714 How do I pass the values of radio buttons to a window created on the fly, rather than using the search function of an existing page?

You are here: irt.org | FAQ | JavaScript | Window | Q714 [ previous next ]

Try this:

<FORM NAME="radioForm">
Question 0? Yes <INPUT TYPE="RADIO" NAME="q0">
No <INPUT TYPE="RADIO" NAME="q0"><BR>
Question 1? Yes <INPUT TYPE="RADIO" NAME="q1">
No <INPUT TYPE="RADIO" NAME="q1"><BR>
Question 2? Yes <INPUT TYPE="RADIO" NAME="q2">
No <INPUT TYPE="RADIO" NAME="q2"><BR>

<P>
<INPUT TYPE="BUTTON" onClick="passAnswers()" VALUE="Finished">
</FORM>

<SCRIPT LANGUAGE="JavaScript"><!--
function passAnswers() {
    var output = '';
    for (var i=0;i<3;i++) {
        if (eval("document.radioForm.q" + i + "[0].checked") == true)
            output += 'Question ' + i + ' = yes';

         if (eval("document.radioForm.q" + i + "[1].checked") == true)
            output += 'Question ' + i + ' = no';
    }

    windowHandle = window.open('blank.htm');
    windowHandle.document.open();
    windowHandle.document.write(output);
    windowHandle.document.close();
}
//--></SCRIPT>

©2018 Martin Webb