View Full Version : Cant get this to print anything out

12-18-2006, 09:00 PM
I am trying to print out a list of apartments according to the building number they select... but it doesn't even print the building number......

<script type="text/Javascript" language="javascript">
var rooms = new Array(
[ "01", [ "0111A", "0111B", "0111C", "0111D",
"0112A", "0112B", "0112C", "0112D",
"0113A", "0113B", "0113C", "0113D",
"0114A", "0114B", "0114C", "0114D",
"0121A", "0121B", "0121C", "0121D",
"0122A", "0122B", "0122C", "0122D",
"0123A", "0123B", "0123C", "0123D",
"0124A", "0124B", "0124C", "0124D",
"0131A", "0131B", "0131C", "0131D",
"0132A", "0132B", "0132C", "0132D",
"0133A", "0133B", "0133C", "0133D",
"0134A", "0134B", "0134C", "0134D",
"0143A", "0143B", "0143C", "0143D",
"0144A", "0144B", "0144C", "0144D" ] ],
[ "02", [ "0211A", "0211B", "0211C", "0211D",
"0212A", "0212B", "0212C", "0212D",
"0213A", "0213B", "0213C", "0213D",
"0214A", "0214B", "0214C", "0214D",
"0221A", "0221B", "0221C", "0221D",
"0222A", "0222B", "0222C", "0222D",
"0223A", "0223B", "0223C", "0223D",
"0224A", "0224B", "0224C", "0224D",
"0231A", "0231B", "0231C", "0231D",
"0232A", "0232B", "0232C", "0232D",
"0233A", "0233B", "0233C", "0233D",
"0234A", "0234B", "0234C", "0234D",
"0243A", "0243B", "0243C", "0243D",
"0244A", "0244B", "0244C", "0244D" ] ])

function select_building() {
var form = document.user_info;
var building_options = form.building.options;
var room_options = form.room_list.options;
var sel_bldg_index = form.building.selectedIndex;
var sel_bldg_val = building_options[sel_bldg_index].value;

for( room_ctr=0; room_ctr &lt; room_options.length; room_ctr++){
room_options[room_ctr] = null;
for( room_ctr = 0; room_ctr &lt; rooms[sel_bldg_index][1].length; room_ctr++){
room_options[room_ctr] = new Option(rooms[sel_bldg_index][1][room_ctr], rooms[sel_bldg_index][1][room_ctr]);


then the print function..

<script type="text/javascript" language="javascript">
function printout()
for( bldg=0; bldg &lt; rooms.length; bldg++){
document.write("\<option value=\"" + rooms[bldg][0] + "\"\>" + rooms[bldg][0] + "\<\/option\><br/>");

and now the php code...

print " <td>";
print " <select size=\"1\" name=\"building\" onchange=\"select_building()\" onclick=\"select_building()\" onfocus=\"select_building()\">";

print " printout();"; //added
print " </select>";

I tried to validate the code to see if it was an easy fix and well I didnt write the functions in the first place so I dont know a whole lot about javascript.. and it give me a few errors...

Error: uncaught exception: [Exception... "Index or size is negative or greater than the allowed amount" code: "1" nsresult: "0x80530001 (NS_ERROR_DOM_INDEX_SIZE_ERR)" location: "mypage Line: 212"]

line 212 is this line --- var sel_bldg_val = building_options[sel_bldg_index].value;

12-19-2006, 02:47 PM
please help