PDA

View Full Version : Object expected



CanCon
02-05-2009, 04:19 PM
Hi! I'm a rookie newbie wannabe Javascript Joker! :o There, now that that's out of the way, hopefully you'll forgive the stupidity of the following:

Some "professional" programmer left me with this code for my business, and although I'm trying to learn it, it seems like he is, too:

<script type="text/javascript">
function setList(url, cnt)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}
url=url+"?"+cnt
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
document.getElementById('form').innerHTML= xmlHttp.responseText;
}
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
//Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
</script>
</head>

<body id="********" onload="setList('golfrounds.php', 'i='+document.getElementById('golfList').value)">

<div id="container">
<div id="header"> <span>
<h1>Unknown.</h1>
</span> </div>
<div id="menu">
<?php include_once "includes/main-navi.php"; ?>
</div>
<div id="row1">
<div id="c1">
<?php include_once "includes/arealeft-summer.php"; ?>
</div>
<div id="content">
<h4>Online Booking</h4>
<p style="margin-bottom: 0;"></p>
<p style="margin-top: 0;">Please specify the services that you're interested in. We'll get back to you ASAP with pricing and any additional information you require. </p>
<p style="margin-bottom: 0;"></p>
<form action="booking4.php" method="post" name="frmbooking3" style="margin-bottom margin-top: 0; margin-top: 0; margin-bottom: 0;":0;">
<table width="513" border="0" cellpadding="0" cellspacing="4">
<tr>
<td valign="top" align="center" width="80"><input type="image" src="images/steps/step1.gif" onClick="document.forms['frmbooking3'].action='booking.php';submit();" /></td>
<td valign="top" align="center" width="80"><input type="image" src="images/steps/step2.gif" onClick="document.forms['frmbooking3'].action='booking2.php';submit();" /></td>
<td valign="top" align="center" width="80"><img src="images/steps/step3-on.gif"/></td>
<td valign="top" align="center" width="80"><input type="image" src="images/steps/step4.gif" onClick="document.forms['frmbooking3'].action='booking4.php';submit();" /></td>
<td valign="top" align="center" width="80"><input type="image" src="images/steps/step5.gif" onClick="document.forms['frmbooking3'].action='booking5.php';submit();" /></td>
</tr>

<tr>
</tr>
</table>

<table width="471" bgcolor="#E9F3E4" class="tablefont" cellpadding="3">
<tr>
<td colspan="3"><hr></td>
</tr>
<tr>
<td colspan="3"><strong>GOLF</strong></td>
</tr>
<tr>
<td colspan="3"> Number of Golf Rounds&nbsp;&nbsp; <select id="golfList" name="order_list2" onChange="setList('golfrounds.php', 'i='+this.value)" style="width:40px;">
<option value=1 selected>1</option>
<option value=2>2</option>
<option value=3>3</option>
<option value=4>4</option>
<option value=5>5</option>
<option value=6>6</option>
</select> </td>
</tr>
<tr><td colspan="3"><div id="form"></div></td>
<!--<td width="22" rowspan="3"></td>
<td width="71" align="right">Date:</td>
<td width="392" > <select name='order1startDateMonth2' onChange=setItemDate('order1',1,0) style="width:100px;">
<option value=1> selected>January</option>
<option value=2>February</option>
<option value=3>March</option>
<option value=4>April</option>
<option value=5>May</option>
<option value=6>June</option>
<option value=7>July</option>
<option value=8>August</option>
<option value=9>September</option>
<option value=10>October</option>
<option value=11>November</option>
<option value=12>December</option>

</select> &nbsp; <select name='order1startDateDay2' onChange=setItemDate('order1',1,0) style="width:40px;">
<option value=1> selected>1</option>
<option value=2>2</option>
<option value=3>3</option>
<option value=4>4</option>
<option value=5>5</option>
<option value=6>6</option>
<option value=7>7</option>
<option value=8>8</option>
<option value=9>9</option>
<option value=10>10</option>
<option value=11>11</option>
<option value=12>12</option>
<option value=13>13</option>
<option value=14>14</option>
<option value=15>15</option>
<option value=16>16</option>
<option value=17>17</option>
<option value=18>18</option>
<option value=19>19</option>
<option value=20>20</option>
<option value=21>21</option>
<option value=22>22</option>
<option value=23>23</option>
<option value=24>24</option>
<option value=25>25</option>
<option value=26>26</option>
<option value=27>27</option>
<option value=28>28</option>
<option value=29>29</option>
<option value=30>30</option>
<option value=31>31</option>

</select> &nbsp; <select name='order1startDateYear2' onChange=setItemDate('order1',1,0) style="width:60px;">
<option value=2009> selected>2009</option>
<option value=2010>2010</option>
<option value=2011>2011</option>
</select> <input type=hidden name='order1startDate' value='9/20/2007'>
<input type=hidden name='order1numdays' value=1> </td>
</tr>
<tr>
<td></td>
<td><table border="0" cellspacing="0" cellpadding="4" width="100%">
<tr>
<td valign="top"> Players&nbsp; <select name="order1item12" style="width:40px;">
<option value=1>1</option>
<option value=2>2</option>
<option value=3>3</option>
<option value=4>4</option>
</select> &nbsp;&nbsp;&nbsp;Carts&nbsp; <select name="order1item2" style="width:40px;">
<option value=1>0</option>
<option value=2>1</option>
<option value=3>2</option>
</select> </td>
</tr>
<tr>
<td valign="top">Preferred Tee Time&nbsp; <select name="order1item3" style="width:80px;">
<option value=6:30 am>6:30 am</option>
<option value=7:00 am>7:00 am</option>
<option value=7:30 am>7:30 am</option>
<option value=8:00 am>8:00 am</option>
<option value=8:30 am>8:30 am</option>
<option value=9:00 am>9:00 am</option>
<option value=9:30 am>9:30 am</option>
<option value=10:00 am>10:00 am</option>
<option value=10:30 am>10:30 am</option>
<option value=11:00 am>11:00 am</option>
<option value=11:30 am>11:30 am</option>
<option value=12:00 pm>12:00 pm</option>
<option value=12:30 pm>12:30 pm</option>
<option value=1:00 pm>1:00 pm</option>
<option value=1:30 pm>1:30 pm</option>
<option value=2:00 pm>2:00 pm</option>
<option value=2:30 pm>2:30 pm</option>
<option value=3:00 pm>3:00 pm</option>
<option value=3:30 pm>3:30 pm</option>
<option value=4:00 pm>4:00 pm</option>
<option value=4:30 pm>4:30 pm</option>
<option value=5:00 pm>5:00 pm</option>
<option value=5:30 pm>5:30 pm</option>
<option value=6:00 pm>6:00 pm</option>
<option value=6:30 pm>6:30 pm</option>
<option value=7:00 pm>7:00 pm</option>
</select></td>
</tr>
</table></td>
</tr>
<tr>
<td valign="top" align="right">Comments</td>
<td> <textarea rows="2" cols="30" name="order1comments2"></textarea> </td>
</tr>
<tr>
<td colspan="3"><hr></td>-->
</tr>
<tr>
<tr><td align="left"><a href="booking4.php"><img src="images/skip-btn.gif"></a></td>
<td><input type="image" src="images/submit-btn.gif" onclick="submit();"></td>
</tr>
</table>

</form>
</div>
<div class="clear" ></div>

</div>

The problem is that when I try to make a change to the month, day, or year on the page, I get the "Object expected" error. I assume the missing object is setItemDate, but I wasn't sure how to create it. Anyone wanna throw me a bone...?

codeexploiter
02-06-2009, 03:24 AM
Can you post the functionality that you want when you change Day, Month and Year select lists. As you've mentioned there is no function - setItemDate in the code furnished in your post. It seems that there is a event attached to a non-existing event handler.

CanCon
02-12-2009, 07:28 PM
Before we go on, remember, there's no such thing as a dumb... yeah.

Anyway, the above-mentioned mess is supposed to describe simple dropdowns for an email form. It is one of several pages included in the form, all of which use setItemDate. I'm not sure why, since each page asks for its own dates. I'm not even sure at this point why setItemDate or any onChange commands need to be there at all. Despite the "object expected" error, the dates themselves all show up on the form in my inbox. Hope this is a lot more helpful than I thought it was.

CanCon
02-12-2009, 08:01 PM
I also got to thinking that maybe setItemdate was supposed to automatically detect the date and have the default option in the dropdown reflect it. It never worked from what I can tell. I removed the setItemdate functions from the code, and now I have no error message when I access the menu. I might still be missing something, however.