adding value to dynamic option

Discussion in 'Javascript' started by Dave Anderson, Mar 4, 2004.

  1. I am attempting to create a 2 part selection box.

    I am filling in the second data with the following array, generated by .asp

    arrayData[0] = 'Process Standards for Professional
    Development|Data-Driven|252'

    arrayData[1] = 'Process Standards for Professional
    Development|Evaluation|253'

    arrayData[2] = 'Process Standards for Professional
    Development|Research-Based|254'

    arrayData[3] = 'Process Standards for Professional Development|Design|255'

    arrayData[4] = 'Process Standards for Professional
    Development|Learning|256'

    arrayData[5] = 'Process Standards for Professional
    Development|Collaboration|257'

    arrayData[6] = 'Content Standards|Equity|258'

    arrayData[7] = 'Content Standards|Quality Teaching|259'

    arrayData[8] = 'Content Standards|Family Involvement|260'

    I am spitting the data with | to display in the second selection. This
    works. However, how do I grab the third string? This is the value for my
    select list.

    function populateData( name, value ) {

    select = window.document.form.SubTopic;
    string = "";

    // 0 - will display the new options only
    // 1 - will display the first existing option plus the new options

    count = 0;

    // Clear the old list (above element 0)

    select.options.length = count;

    for( i = 0; i < arrayData.length; i++ ) {
    string = arrayData.split( "|" );
    if( string[0] == name ) {
    select.options[count++] = new Option( string[1]);
    }

    My html

    <select name="SubTopic" size=3 style="width:300;">
    </select>
     
    Dave Anderson, Mar 4, 2004
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.