SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Member
    Join Date
    Nov 2009
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation Dependant DropDowns to Text Field

    I have a page with 6 dependant drop down boxes. I also have a text field with a copy to clipboard button.

    What I need it to do is send the drop down selections to the text field to be copied along with some static text. The resulting text field would look something like this after the selections are made.

    "Per Wizard: Choice 0: Selection 2, Choice 1: Selection 2, Choice 2: Selection 4 ..."

    Can this be done on each line as a second onChange event?

    Code:
    <html>
    
    <head>
    <HEAD>
    
    <script type="text/javascript">
    <!--
    var arrItems1 = new Array();
    var arrItemsGrp1 = new Array();
    
    arrItems1[1] = "Selection 1";
    arrItemsGrp1[1] = 1;
    arrItems1[2] = "Selection 2";
    arrItemsGrp1[2] = 1;
    arrItems1[3] = "Selection 3";
    arrItemsGrp1[3] = 1;
    
    var arrItems2 = new Array();
    var arrItemsGrp2 = new Array();
    
    arrItems2[12] = "Selection 1";
    arrItemsGrp2[12] = 1
    arrItems2[13] = "Selection 2";
    arrItemsGrp2[13] = 1
    arrItems2[14] = "Selection 3";
    arrItemsGrp2[14] = 1
    arrItems2[15] = "Selection 4";
    arrItemsGrp2[15] = 1
    arrItems2[16] = "Selection 5";
    arrItemsGrp2[16] = 1
    arrItems2[17] = "Selection 6";
    arrItemsGrp2[17] = 1
    
    var arrItems3 = new Array();
    var arrItemsGrp3 = new Array();
    
    arrItems3[42] = "Selection 1";
    arrItemsGrp3[42] = 12
    arrItems3[43] = "Selection 2";
    arrItemsGrp3[43] = 12
    arrItems3[44] = "Selection 3";
    arrItemsGrp3[44] = 12
    
    var arrItems4 = new Array();
    var arrItemsGrp4 = new Array();
    
    arrItems4[133] = "Selection 1";
    arrItemsGrp4[133] = 42
    
    var arrItems5 = new Array();
    var arrItemsGrp5 = new Array();
    
    arrItems5[244] = "Selection 1";
    arrItemsGrp5[244] = 133
    arrItems5[245] = "Selection 2";
    arrItemsGrp5[245] = 133
    
    function selectChange(control,nu){
    var frm=control.form;
    var sel=frm['Choice'+nu];
    var iary=window['arrItems'+nu];
    var gary=window['arrItemsGrp'+nu];
    var cnt=1;
    while (frm['Choice'+cnt]){
    if (cnt>=nu){
    while (frm['Choice'+cnt].firstChild){
    frm['Choice'+cnt].removeChild(frm['Choice'+cnt].firstChild);
    }
    }
    cnt++;
    }
    var myEle=document.createElement("option");
    myEle.appendChild(document.createTextNode("[SELECT ONE]"));
    myEle.setAttribute("value","0");
    sel.appendChild(myEle);
    for (var x = 0 ; x < iary.length ; x++ ) {
    if ( gary[x]==control.value ) {
    myEle = document.createElement("option");
    myEle.setAttribute("value",x);
    myEle.appendChild(document.createTextNode(iary[x]));
    sel.appendChild(myEle);
    }
    }
    }
    // -->
    </script>
    <script language='Javascript'>
    function doact(d)
    {
    var doc = eval("document.form."+d);
    cp = doc.createTextRange();
    doc.focus();
    doc.select();
    cp.execCommand("Copy");
    }
    
    function FP_popUpMsg(msg) {//v1.0
    alert(msg);
    }
    </script>
    </HEAD>
    
    <BODY>
    
    <form name=form>
    <div align="center">
    <table border="2" width="790" id="table1" bordercolor="#64367C">
    <tr>
    <td width="778" align="left" colspan="2">
    &nbsp;</td>
    <tr>
    <td width="305" align="left">
    <font size="2" face="MS Sans Serif">&nbsp;Choice 1:<font size="2" face="MS Sans Serif">
    <select id="Choice0" name="Choice0" onchange="selectChange(this, 1);">
    <option value="0" selected>[SELECT]</option>
    <option value="1">Selection 1</option>
    <option value="2">Selection 2</option>
    <option value="3">Selection 3</option>
    </select></font></font></td>
    <td width="225" align="center" onclick="FP_popUpMsg('More Info')">
    <font face="MS Sans Serif" size="2" color="#FF0000">*</font><font face="MS Sans Serif" size="2" color="#0000FF">
    <u>
    Tell me more</u></font></td>
    <tr>
    <td width="547" align="left">
    <font size="2" face="MS Sans Serif">&nbsp;&nbsp;&nbsp; Code 2: 
    <select id="secondChoice" name="Choice1" onchange="selectChange(this, 2); "></select></font></td>
    <td width="225" align="center" rowspan="4">
    <TEXTAREA name="text1" cols="25" rows="5">
    Selections will populate here.
    </TEXTAREA><input onclick="doact('text1')" type="button" value="Copy">
    </td>
    </tr>
    <tr>
    <td width="547" align="left">
    <font size="2" face="MS Sans Serif">&nbsp;&nbsp;&nbsp; Code 3: 
    <select id="thirdChoice" name="Choice2" onchange="selectChange(this, 3);"></select></font></td>
    </tr>
    <tr>
    <td width="547" align="left">
    <font size="2" face="MS Sans Serif">&nbsp;&nbsp;&nbsp; Code 4: 
    <select id="fourthChoice" name="Choice3" onchange="selectChange(this, 4);"></select></font></td>
    </tr>
    <tr>
    <td width="547" align="left">
    <font face="MS Sans Serif" size="2">&nbsp;&nbsp;&nbsp;&nbsp;Code 5: </font> <font size="3" face="Courier">
    <select id="fifthChoice" name="Choice4" onchange="selectChange(this, 5);" size="1"></select></font></td>
    </tr>
    <tr>
    <td width="547" align="left">
    <p><font face="MS Sans Serif" size="2">&nbsp;&nbsp;&nbsp; Answer: </font>
    <font size="3" face="Courier">
    <select id="sixthChoice" name="Choice5" onChange="alert('Reminder')" size="1"></select>
    </font></p></td>
    <td width="225" align="center">
    <font size="2" face="MS Sans Serif">
    <a target="_blank" href="reference.htm">Show the Full Spreadsheet</a></a></font></td>
    </tr>
    <tr>
    <td width="778" align="left" colspan="2">
    &nbsp;</td>
    </tr>
    </table>
    </div>
    </form>
    
    </body>
    
    </html>
    Last edited by LauraWord; Nov 11, 2009 at 13:37. Reason: add code tags

  2. #2
    SitePoint Zealot
    Join Date
    May 2009
    Location
    Netherlands
    Posts
    189
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Call this as the first line in function selectChange
    Code:
    function listChoices() {
    var textStr='';
    var aSel=document.getElementsByTagName('select');
    for(var i=0; i<aSel.length; i++) {
        if(aSel[i].length>1) {
            textStr+=aSel[i].name+": "+aSel[i][aSel[i].value].text+",";
            }
        }
    document.form.text1.value=textStr;
    }

  3. #3
    SitePoint Member
    Join Date
    Nov 2009
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation

    Thanks so much for your help!

    This is exactly what I am looking for but it only works for the first two fields and only for a few selections. My actual sheet has hundreds of options. Is there a way to make it work for six boxes and an unlimited number of options?

  4. #4
    SitePoint Wizard PHPycho's Avatar
    Join Date
    Dec 2005
    Posts
    1,201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I use ajax instead of such static array replacement.
    What if the size of array is very big?

  5. #5
    SitePoint Wizard PHPycho's Avatar
    Join Date
    Dec 2005
    Posts
    1,201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I use ajax instead of such static array replacement.
    What if the size of array is very big?

  6. #6
    SitePoint Zealot
    Join Date
    May 2009
    Location
    Netherlands
    Posts
    189
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I can't see a user would bother to look at hundreds of options. Perhaps you need to re-organize your data.

  7. #7
    SitePoint Member
    Join Date
    Nov 2009
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am simulating another system, so I don't control the number of options, but there is only 7 in the first box and each of them prompts a different short list of 3 to 6, which each prompts another short list so the total number grows pretty fast.

  8. #8
    SitePoint Zealot
    Join Date
    May 2009
    Location
    Netherlands
    Posts
    189
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by LauraWord View Post
    Thanks so much for your help!

    This is exactly what I am looking for but it only works for the first two fields and only for a few selections. My actual sheet has hundreds of options. Is there a way to make it work for six boxes and an unlimited number of options?
    It works for any number of select boxes.

  9. #9
    SitePoint Member
    Join Date
    Nov 2009
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can you look at my code and see if I am doing something wrong? The first two work perfectly but I get an error ('text' is null or not an oject) when I change the third field.

    Code:
    <html>
    
    <head>
    
    <script type="text/javascript">
    <!--
    var arrItems1 = new Array();
    var arrItemsGrp1 = new Array();
    
    arrItems1[1] = "Selection 1";
    arrItemsGrp1[1] = 1
    arrItems1[2] = "Selection 2";
    arrItemsGrp1[2] = 1
    arrItems1[3] = "Selection 1";
    arrItemsGrp1[3] = 2
    arrItems1[4] = "Selection 2";
    arrItemsGrp1[4] = 2
    arrItems1[5] = "Selection 1";
    arrItemsGrp1[5] = 3
    arrItems1[6] = "Selection 2";
    arrItemsGrp1[6] = 3
    
    
    var arrItems2 = new Array();
    var arrItemsGrp2 = new Array();
    
    arrItems2[12] = "Selection 1";
    arrItemsGrp2[12] = 1
    arrItems2[13] = "Selection 2";
    arrItemsGrp2[13] = 1
    arrItems2[14] = "Selection 1";
    arrItemsGrp2[14] = 2
    arrItems2[15] = "Selection 2";
    arrItemsGrp2[15] = 2
    arrItems2[16] = "Selection 1";
    arrItemsGrp2[16] = 3
    arrItems2[17] = "Selection 2";
    arrItemsGrp2[17] = 3
    arrItems2[18] = "Selection 1";
    arrItemsGrp2[18] = 4
    arrItems2[19] = "Selection 2";
    arrItemsGrp2[19] = 4
    arrItems2[20] = "Selection 1";
    arrItemsGrp2[20] = 5
    arrItems2[21] = "Selection 2";
    arrItemsGrp2[21] = 5
    arrItems2[22] = "Selection 1";
    arrItemsGrp2[22] = 6
    arrItems2[23] = "Selection 2";
    arrItemsGrp2[23] = 6
    
    var arrItems3 = new Array();
    var arrItemsGrp3 = new Array();
    
    arrItems3[42] = "Selection 1";
    arrItemsGrp3[42] = 12
    arrItems3[43] = "Selection 2";
    arrItemsGrp3[43] = 12
    arrItems3[44] = "Selection 1";
    arrItemsGrp3[44] = 13
    arrItems3[45] = "Selection 2";
    arrItemsGrp3[45] = 13
    arrItems3[46] = "Selection 1";
    arrItemsGrp3[46] = 14
    arrItems3[47] = "Selection 2";
    arrItemsGrp3[47] = 14
    arrItems3[48] = "Selection 1";
    arrItemsGrp3[48] = 15
    arrItems3[49] = "Selection 2";
    arrItemsGrp3[49] = 15
    arrItems3[50] = "Selection 1";
    arrItemsGrp3[50] = 16
    arrItems3[51] = "Selection 2";
    arrItemsGrp3[51] = 16
    arrItems3[52] = "Selection 1";
    arrItemsGrp3[52] = 17
    arrItems3[53] = "Selection 2";
    arrItemsGrp3[53] = 17
    arrItems3[54] = "Selection 1";
    arrItemsGrp3[54] = 18
    arrItems3[55] = "Selection 2";
    arrItemsGrp3[55] = 18
    arrItems3[56] = "Selection 1";
    arrItemsGrp3[56] = 19
    arrItems3[57] = "Selection 2";
    arrItemsGrp3[57] = 19
    arrItems3[58] = "Selection 1";
    arrItemsGrp3[58] = 20
    arrItems3[59] = "Selection 2";
    arrItemsGrp3[59] = 20
    arrItems3[60] = "Selection 1";
    arrItemsGrp3[60] = 21
    arrItems3[61] = "Selection 2";
    arrItemsGrp3[61] = 21
    arrItems3[62] = "Selection 1";
    arrItemsGrp3[62] = 22
    arrItems3[63] = "Selection 2";
    arrItemsGrp3[63] = 22
    
    var arrItems4 = new Array();
    var arrItemsGrp4 = new Array();
    
    arrItems3[133] = "Selection 1";
    arrItemsGrp3[133] = 42
    arrItems3[134] = "Selection 2";
    arrItemsGrp3[134] = 42
    arrItems3[135] = "Selection 1";
    arrItemsGrp3[135] = 43
    arrItems3[136] = "Selection 2";
    arrItemsGrp3[136] = 43
    arrItems3[137] = "Selection 1";
    arrItemsGrp3[137] = 44
    arrItems3[138] = "Selection 2";
    arrItemsGrp3[138] = 44
    arrItems3[139] = "Selection 1";
    arrItemsGrp3[139] = 45
    arrItems3[140] = "Selection 2";
    arrItemsGrp3[140] = 45
    arrItems3[141] = "Selection 1";
    arrItemsGrp3[141] = 46
    arrItems3[142] = "Selection 2";
    arrItemsGrp3[142] = 46
    arrItems3[143] = "Selection 1";
    arrItemsGrp3[143] = 47
    arrItems3[144] = "Selection 2";
    arrItemsGrp3[144] = 47
    arrItems3[145] = "Selection 1";
    arrItemsGrp3[145] = 48
    arrItems3[146] = "Selection 2";
    arrItemsGrp3[146] = 48
    arrItems3[147] = "Selection 1";
    arrItemsGrp3[147] = 49
    arrItems3[148] = "Selection 2";
    arrItemsGrp3[148] = 49
    arrItems3[149] = "Selection 1";
    arrItemsGrp3[149] = 50
    arrItems3[150] = "Selection 2";
    arrItemsGrp3[150] = 50
    arrItems3[151] = "Selection 1";
    arrItemsGrp3[151] = 51
    arrItems3[152] = "Selection 2";
    arrItemsGrp3[152] = 51
    arrItems3[153] = "Selection 1";
    arrItemsGrp3[153] = 52
    arrItems3[154] = "Selection 2";
    arrItemsGrp3[154] = 52
    arrItems3[155] = "Selection 1";
    arrItemsGrp3[155] = 53
    arrItems3[156] = "Selection 2";
    arrItemsGrp3[156] = 53
    arrItems3[157] = "Selection 1";
    arrItemsGrp3[157] = 54
    arrItems3[158] = "Selection 2";
    arrItemsGrp3[158] = 54
    arrItems3[159] = "Selection 1";
    arrItemsGrp3[159] = 55
    arrItems3[160] = "Selection 2";
    arrItemsGrp3[160] = 55
    arrItems3[161] = "Selection 1";
    arrItemsGrp3[161] = 56
    arrItems3[162] = "Selection 2";
    arrItemsGrp3[162] = 56
    arrItems3[163] = "Selection 1";
    arrItemsGrp3[163] = 57
    arrItems3[164] = "Selection 2";
    arrItemsGrp3[164] = 57
    arrItems3[165] = "Selection 1";
    arrItemsGrp3[165] = 58
    arrItems3[166] = "Selection 2";
    arrItemsGrp3[166] = 58
    arrItems3[167] = "Selection 1";
    arrItemsGrp3[167] = 59
    arrItems3[168] = "Selection 2";
    arrItemsGrp3[168] = 59
    arrItems3[169] = "Selection 1";
    arrItemsGrp3[169] = 60
    arrItems3[170] = "Selection 2";
    arrItemsGrp3[170] = 60
    arrItems3[17] = "Selection 1";
    arrItemsGrp3[171] = 61
    arrItems3[172] = "Selection 2";
    arrItemsGrp3[172] = 61
    arrItems3[173] = "Selection 1";
    arrItemsGrp3[173] = 62
    arrItems3[174] = "Selection 2";
    arrItemsGrp3[174] = 62
    
    var arrItems5 = new Array();
    var arrItemsGrp5 = new Array();
    
    arrItems5[244] = "Selection 1";
    arrItemsGrp5[244] = 133
    arrItems5[245] = "Selection 2";
    arrItemsGrp5[245] = 133
    arrItems3[246] = "Selection 1";
    arrItemsGrp3[246] = 134
    arrItems3[247] = "Selection 2";
    arrItemsGrp3[247] = 134
    arrItems3[248] = "Selection 1";
    arrItemsGrp3[248] = 135
    arrItems3[249] = "Selection 2";
    arrItemsGrp3[249] = 135
    arrItems3[250] = "Selection 1";
    arrItemsGrp3[250] = 136
    arrItems3[251] = "Selection 2";
    arrItemsGrp3[251] = 136
    arrItems3[252] = "Selection 1";
    arrItemsGrp3[252] = 137
    arrItems3[253] = "Selection 2";
    arrItemsGrp3[253] = 137
    arrItems3[254] = "Selection 1";
    arrItemsGrp3[254] = 138
    arrItems3[255] = "Selection 2";
    arrItemsGrp3[255] = 138
    arrItems3[256] = "Selection 1";
    arrItemsGrp3[256] = 139
    arrItems3[257] = "Selection 2";
    arrItemsGrp3[257] = 139
    arrItems3[258] = "Selection 1";
    arrItemsGrp3[258] = 140
    arrItems3[259] = "Selection 2";
    arrItemsGrp3[259] = 140
    arrItems3[260] = "Selection 1";
    arrItemsGrp3[260] = 141
    arrItems3[261] = "Selection 2";
    arrItemsGrp3[261] = 141
    arrItems3[262] = "Selection 1";
    arrItemsGrp3[262] = 142
    arrItems3[263] = "Selection 2";
    arrItemsGrp3[263] = 142
    arrItems3[264] = "Selection 1";
    arrItemsGrp3[264] = 143
    arrItems3[265] = "Selection 2";
    arrItemsGrp3[265] = 143
    arrItems3[266] = "Selection 1";
    arrItemsGrp3[266] = 144
    arrItems3[267] = "Selection 2";
    arrItemsGrp3[267] = 144
    arrItems3[268] = "Selection 1";
    arrItemsGrp3[268] = 145
    arrItems3[269] = "Selection 2";
    arrItemsGrp3[269] = 145
    arrItems3[270] = "Selection 1";
    arrItemsGrp3[270] = 146
    arrItems3[271] = "Selection 2";
    arrItemsGrp3[271] = 146
    arrItems3[272] = "Selection 1";
    arrItemsGrp3[272] = 147
    arrItems3[273] = "Selection 2";
    arrItemsGrp3[273] = 147
    arrItems3[274] = "Selection 1";
    arrItemsGrp3[274] = 148
    arrItems3[275] = "Selection 2";
    arrItemsGrp3[275] = 148
    arrItems3[276] = "Selection 1";
    arrItemsGrp3[276] = 149
    arrItems3[277] = "Selection 2";
    arrItemsGrp3[277] = 149
    arrItems3[278] = "Selection 1";
    arrItemsGrp3[278] = 150
    arrItems3[279] = "Selection 2";
    arrItemsGrp3[279] = 150
    arrItems3[280] = "Selection 1";
    arrItemsGrp3[280] = 151
    arrItems3[281] = "Selection 2";
    arrItemsGrp3[281] = 151
    arrItems3[282] = "Selection 1";
    arrItemsGrp3[282] = 152
    arrItems3[283] = "Selection 2";
    arrItemsGrp3[283] = 152
    arrItems3[284] = "Selection 1";
    arrItemsGrp3[284] = 153
    arrItems3[285] = "Selection 2";
    arrItemsGrp3[285] = 153
    arrItems3[286] = "Selection 1";
    arrItemsGrp3[286] = 154
    arrItems3[287] = "Selection 2";
    arrItemsGrp3[287] = 154
    arrItems3[288] = "Selection 1";
    arrItemsGrp3[288] = 155
    arrItems3[289] = "Selection 2";
    arrItemsGrp3[289] = 155
    arrItems3[290] = "Selection 1";
    arrItemsGrp3[290] = 156
    arrItems3[291] = "Selection 2";
    arrItemsGrp3[291] = 156
    arrItems3[292] = "Selection 1";
    arrItemsGrp3[292] = 157
    arrItems3[293] = "Selection 2";
    arrItemsGrp3[293] = 157
    arrItems3[294] = "Selection 1";
    arrItemsGrp3[294] = 158
    arrItems3[295] = "Selection 2";
    arrItemsGrp3[295] = 158
    arrItems3[296] = "Selection 1";
    arrItemsGrp3[296] = 159
    arrItems3[297] = "Selection 2";
    arrItemsGrp3[297] = 159
    arrItems3[298] = "Selection 1";
    arrItemsGrp3[298] = 160
    arrItems3[299] = "Selection 2";
    arrItemsGrp3[299] = 160
    arrItems3[300] = "Selection 1";
    arrItemsGrp3[300] = 161
    arrItems3[301] = "Selection 2";
    arrItemsGrp3[301] = 161
    arrItems3[302] = "Selection 1";
    arrItemsGrp3[302] = 162
    arrItems3[303] = "Selection 2";
    arrItemsGrp3[303] = 162
    arrItems3[304] = "Selection 1";
    arrItemsGrp3[304] = 163
    arrItems3[305] = "Selection 2";
    arrItemsGrp3[305] = 163
    arrItems3[306] = "Selection 1";
    arrItemsGrp3[306] = 164
    arrItems3[307] = "Selection 2";
    arrItemsGrp3[307] = 164
    arrItems3[308] = "Selection 1";
    arrItemsGrp3[308] = 165
    arrItems3[309] = "Selection 2";
    arrItemsGrp3[309] = 165
    arrItems3[310] = "Selection 1";
    arrItemsGrp3[310] = 166
    arrItems3[311] = "Selection 2";
    arrItemsGrp3[311] = 166
    arrItems3[312] = "Selection 1";
    arrItemsGrp3[312] = 167
    arrItems3[313] = "Selection 2";
    arrItemsGrp3[313] = 167
    arrItems3[314] = "Selection 1";
    arrItemsGrp3[314] = 168
    arrItems3[315] = "Selection 2";
    arrItemsGrp3[315] = 168
    arrItems3[316] = "Selection 1";
    arrItemsGrp3[316] = 169
    arrItems3[317] = "Selection 2";
    arrItemsGrp3[317] = 169
    arrItems3[318] = "Selection 1";
    arrItemsGrp3[318] = 170
    arrItems3[319] = "Selection 2";
    arrItemsGrp3[319] = 170
    arrItems3[320] = "Selection 1";
    arrItemsGrp3[320] = 171
    arrItems3[321] = "Selection 2";
    arrItemsGrp3[321] = 171
    arrItems3[322] = "Selection 1";
    arrItemsGrp3[322] = 172
    arrItems3[323] = "Selection 2";
    arrItemsGrp3[323] = 172
    arrItems3[324] = "Selection 1";
    arrItemsGrp3[324] = 173
    arrItems3[325] = "Selection 2";
    arrItemsGrp3[325] = 173
    arrItems3[326] = "Selection 1";
    arrItemsGrp3[326] = 174
    arrItems3[327] = "Selection 2";
    arrItemsGrp3[327] = 174
    
    
    function selectChange(control,nu){
    var frm=control.form;
    var sel=frm['Choice'+nu];
    var iary=window['arrItems'+nu];
    var gary=window['arrItemsGrp'+nu];
    var cnt=1;
    while (frm['Choice'+cnt]){
    if (cnt>=nu){
    while (frm['Choice'+cnt].firstChild){
    frm['Choice'+cnt].removeChild(frm['Choice'+cnt].firstChild);
    }
    }
    cnt++;
    }
    var myEle=document.createElement("option");
    myEle.appendChild(document.createTextNode("[SELECT ONE]"));
    myEle.setAttribute("value","0");
    sel.appendChild(myEle);
    for (var x = 0 ; x < iary.length ; x++ ) {
    if ( gary[x]==control.value ) {
    myEle = document.createElement("option");
    myEle.setAttribute("value",x);
    myEle.appendChild(document.createTextNode(iary[x]));
    sel.appendChild(myEle);
    }
    }
    }
    // -->
    </script>
    <script language='Javascript'>
    function doact(d)
    {
    var doc = eval("document.form."+d);
    cp = doc.createTextRange();
    doc.focus();
    doc.select();
    cp.execCommand("Copy");
    }
    
    function FP_popUpMsg(msg) {//v1.0
    alert(msg);
    }
    </script>
    <script language='Javascript'>
    function listChoices() {
    var textStr='';
    var aSel=document.getElementsByTagName('select');
    for(var i=0; i<aSel.length; i++) {
        if(aSel[i].length>1) {
            textStr+=aSel[i].name+": "+aSel[i][aSel[i].value].text+",";
            }
        }
    document.form.text1.value=textStr;
    }
    </script>
    </HEAD>
    
    <BODY>
    
    <form name=form>
    <div align="center">
    <table border="2" width="790" id="table1" bordercolor="#64367C">
    <tr>
    <td width="778" align="left" colspan="2">
    &nbsp;</td>
    <tr>
    <td width="305" align="left">
    <font size="2" face="MS Sans Serif">&nbsp;Choice 1:<font size="2" face="MS Sans Serif">
    <select id="Choice0" name="Choice0" onchange="listChoices(); selectChange(this, 1);">
    <option value="0" selected>[SELECT]</option>
    <option value="1">Selection 1</option>
    <option value="2">Selection 2</option>
    <option value="3">Selection 3</option>
    </select></font></font></td>
    <td width="225" align="center" onclick="FP_popUpMsg('More Info')">
    <font face="MS Sans Serif" size="2" color="#FF0000">*</font><font face="MS Sans Serif" size="2" color="#0000FF">
    <u>
    Tell me more</u></font></td>
    <tr>
    <td width="547" align="left">
    <font size="2" face="MS Sans Serif">&nbsp;&nbsp;&nbsp; Code 2: 
    <select id="secondChoice" name="Choice1" onchange="listChoices(); selectChange(this, 2); "></select></font></td>
    <td width="225" align="center" rowspan="4">
    <TEXTAREA name="text1" cols="25" rows="5">
    Selections will populate here.
    </TEXTAREA><input onclick="doact('text1')" type="button" value="Copy">
    </td>
    </tr>
    <tr>
    <td width="547" align="left">
    <font size="2" face="MS Sans Serif">&nbsp;&nbsp;&nbsp; Code 3: 
    <select id="thirdChoice" name="Choice2" onchange="listChoices(); selectChange(this, 3);"></select></font></td>
    </tr>
    <tr>
    <td width="547" align="left">
    <font size="2" face="MS Sans Serif">&nbsp;&nbsp;&nbsp; Code 4: 
    <select id="fourthChoice" name="Choice3" onchange="listChoices(); selectChange(this, 4);"></select></font></td>
    </tr>
    <tr>
    <td width="547" align="left">
    <font face="MS Sans Serif" size="2">&nbsp;&nbsp;&nbsp;&nbsp;Code 5: </font> <font size="3" face="Courier">
    <select id="fifthChoice" name="Choice4" onchange="listChoices(); selectChange(this, 5);" size="1"></select></font></td>
    </tr>
    <tr>
    <td width="547" align="left">
    <p><font face="MS Sans Serif" size="2">&nbsp;&nbsp;&nbsp; Answer: </font>
    <font size="3" face="Courier">
    <select id="sixthChoice" name="Choice5" onChange="listChoices(); alert('Reminder')" size="1"></select>
    </font></p></td>
    <td width="225" align="center">
    <font size="2" face="MS Sans Serif">
    <a target="_blank" href="reference.htm">Show the Full Spreadsheet</a></a></font></td>
    </tr>
    <tr>
    <td width="778" align="left" colspan="2">
    &nbsp;</td>
    </tr>
    </table>
    </div>
    </form>
    
    </body>
    
    </html>

  10. #10
    SitePoint Zealot
    Join Date
    May 2009
    Location
    Netherlands
    Posts
    189
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Change this line:
    Code:
    textStr+=aSel[i].name+": "+aSel[i][aSel[i].selectedIndex].text+",";

  11. #11
    SitePoint Member
    Join Date
    Nov 2009
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That is perfect!!! Thank you so much!!!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •