I have a web page created using plsql web toolkit. I want to set the text box values for street line 2 and zip based on user selection in select drop down which is street line 1. The select drop down list is based on a cursor selecting data from the Oracle database. I'm not sure if I need to use an array in the javascript code or if I can set the values some where in my package.

Cursor:
cursor bldglistc
is
select stvbldg_code,
stvbldg_desc,
slbbldg_street_line1,
slbbldg_city,
slbbldg_stat_code,
slbbldg_zip
from stvbldg, slbbldg
where stvbldg_code = slbbldg_bldg_code (+)
and stvbldg_desc not like 'DNU%'
and stvbldg_desc not like 'Online%'
order by slbbldg_bldg_code;

bldg_record bldglistc%ROWTYPE;
From package:
Javascript:
htp.p('
<SCRIPT LANGUAGE="JavaScript" TYPE = "text/javascript">
function UpdateNextField(which1,which2,fld1,fld2) {
document.getElementById(fld1).value = which1.value;
document.getElementById(fld2).value = which2.value;
}

</SCRIPT>
');
Form:
HTP.formopen ('bwgkogad.P_ProcAddrUpdate', 'post');
twbkfrmt.P_FormHidden ('atyp', atyp);
twbkfrmt.P_FormHidden ('seqno', seqno);


twbkfrmt.p_tableopen (
'DATAENTRY',
cattributes =>G$_NLS.Get('BWGKOAD1-0003','SQL','SUMMARY="This table shows Address Selected for Update."')
);
twbkfrmt.p_tablerowopen;
twbkfrmt.p_tabledataheader (stvatyp_rec.stvatyp_desc, ccolspan => '5');
twbkfrmt.p_tablerowclose;

twbkfrmt.p_tablerowopen;
twbkfrmt.p_tabledatalabel (
twbkfrmt.f_formlabel (
g$_nls.get ('BWGKOAD1-0007', 'SQL', 'Address Line 1:'),
idname => 'street_line1_input_id'
)
);
twbkfrmt.p_tabledataopen (ccolspan => '5');
HTP.formselectopen (
'str1',
'',
1,
cattributes => 'ID="street_line1_input_id" onChange="javascript: UpdateNextField(this,this,''street_line2_input_id' ',''zip_input_id'')"'
);


OPEN bldglistc;

LOOP
FETCH bldglistc INTO bldg_record;

IF bldglistc%NOTFOUND
THEN
EXIT;
END IF;

IF address_rec.spraddr_street_line1 = bldg_record.slbbldg_street_line1
THEN
twbkwbis.p_formselectoption (
bldg_record.slbbldg_street_line1,
bldg_record.slbbldg_street_line1,
'selected'
);
ELSE
twbkwbis.p_formselectoption (
bldg_record.slbbldg_street_line1,
bldg_record.slbbldg_street_line1
);
END IF;
END LOOP;

CLOSE bldglistc;

HTP.formselectclose;
twbkfrmt.p_tabledataclose;
twbkfrmt.p_tablerowclose;


twbkfrmt.p_tablerowopen;
twbkfrmt.p_tabledatalabel (
twbkfrmt.f_formlabel (
g$_nls.get ('BWGKOAD1-0008', 'SQL', 'Address Line 2:'),
idname => 'street_line2_input_id'
)
);
twbkfrmt.p_tabledata (
twbkfrmt.f_formtext (
'str2',
70,
75,
address_rec.spraddr_street_line2,
cattributes => 'ID="street_line2_input_id" readonly'
),
ccolspan => '5'
);
twbkfrmt.p_tablerowclose;

twbkfrmt.p_tablerowopen;
twbkfrmt.p_tabledatalabel (
twbkfrmt.f_formlabel (
g$_nls.get ('BWGKOAD1-0013', 'SQL', 'ZIP or Postal Code:'),
idname => 'zip_input_id'
)
);
twbkfrmt.p_tabledata (
twbkfrmt.f_formtext (
'zip',
NULL,
30,
address_rec.spraddr_zip,
cattributes => 'ID="zip_input_id" readonly'
),
ccolspan => '5'
);
twbkfrmt.p_tablerowclose;

twbkfrmt.p_tableclose;
HTP.para;
--
HTP.formsubmit (NULL, G$_NLS.Get('BWGKOAD1-0054','SQL','Submit'));
HTP.formreset (g$_nls.get ('BWGKOAD1-0055', 'SQL', 'Reset'));
HTP.formclose;