Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with Javascript string being sent to function...

Status
Not open for further replies.

Actorial

Programmer
Aug 23, 2006
38
0
0
US
Hi,

I have a php page which is calling a javascript function that checks a hotel reservation database to see if the property is available. The reserved dates are provided as a string (php array imploded with a space between values) to the js function, and the js function create an array out of this string and then checks to see if the submitted timeperiod contiains each date stamp.

I keep getting "error object expected." At first I thought the string might be too long, but I don't think that is the case.

Code:
<from action="form.php"  method="post" enctype="application/x-[URL unfurl="true"]www-form-urlencoded"[/URL] name="CheckAvailability21" id="frmCheckAvailability21" onsubmit="return checkform(this, '1188619200 1188705600 1188792000 1188878400 1188964800 1189051200 1189137600 1189224000 1189310400 1189396800 1189483200 1189569600 1189656000 1189742400 1189828800 1189915200 1190001600 1190088000 1190174400 1190260800 1190347200 1190433600 1190520000 1190606400 1190692800 1190779200 1190865600 1190952000 1191038400 1191124800')">

then I have a javascript function:

Code:
function checkform ( form, temp )
{
 var start_date = new Date(form.start_year.value,form.start_month.value-1,form.start_day.value);
  var end_date = new Date(form.end_year.value,form.end_month.value-1,form.end_day.value); 
  if(temp != ''){
	var a = new Array();
  	a = temp.split(' ');
  	for(p=0;p<a.length;p++){
	  //alert(a[p]);
	res_date = new Date();
	res_date.setTime(1000*(a[p])-75600000);
	alert( start_date+"<="+res_date+"<"+end_date );
  	if ((res_date>=start_date)&&(res_date<end_date)) {
  	alert( "This property is already reserved during this time period." );
    	form.start_month.focus();
    	return false;
  	}
  }
}
}

Any help you can provide will be much appreciated!

Thank you.
 
I suggest you attempt to visit this page using Firefox (with the Firebug extension installed). This will give you a LOT more useful information that just "Error Object Expected".

Thanks M$ for creating such a useful error reporting system in your flagship web product.

Cheers,
Jeff


[tt]Jeff's Page [!]@[/!] Code Couch
[/tt]

Make sure your web page and css validates properly against the doctype you have chosen - before you attempt to debug a problem!

FAQ216-6094
 
Wow - thanks for the tip with firebug, so much easier to debug now.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top