...

View Full Version : Obect Expected and Object Required Issue



nest9
12-01-2012, 08:00 PM
This is part 2 (maybe 3) to my problem. When debugging the script, I get the following errors : Object expected character 9 this is near the bottom of the page and Object required character 3 this is about 3/4 down the page.I have highlighted the referenced part of the code below with the same color here to hopefully make it easier. I have had to remove some of the beginning cose due to character limitations here.


// See if "user" is valid
if (user.match(userPat)==null) {
// user is not valid
rv = "The username doesn't seem to be valid.";
return rv;
}
/* if the e-mail address is at an IP address (as opposed to a symbolic
host name) make sure the IP address is valid. */
var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {
// this is an IP address
for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
rv = "Destination IP address is invalid!";
return rv;
}
}
return rv;
}
// Domain is symbolic name. Check if it's valid.
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
rv = "The domain name does not seem to be valid.";
return rv;
}
}
/* domain name seems valid, but now make sure that it ends in a
known top-level domain (like com, edu, gov) or a two-letter word,
representing country (uk, nl), and that there's a hostname preceding
the domain or country. */
if (checkTLD && domArr[domArr.length-1].length!=2 &&
domArr[domArr.length-1].search(knownDomsPat)==-1) {
rv = "The address must end in a well-known domain or two letter " + "country.";
return rv;
}

// Make sure there's a host name preceding the domain.
if (len<2) {
rv = "This address is missing a hostname!";
return rv;
}
// If we've gotten this far, everything's valid!
return rv;
}
// End -->
function chk_url(obj) {
var url=obj.value;

if((url.substr(0,7)=='http://' || url.substr(0,7)=='HTTP://' || url.substr(0,8)=='https://' || url.substr(0,8)=='HTTPS://') && url.length > 10)
{
return '';
}
else {
return "The given URL is invalid. (HTTP / HTTPS must be included)";
}
}
function flag_frm(err, objname, errstr, nochange) {
var o = MM_findObj(objname + '_txt');
var objtext = origtext[objname];
var rv;

if (err) {
o.style.color = 'FF0000';
o.innerHTML = '<strong>' + objtext + '</strong>' + '<BR>&nbsp;&nbsp;' + errstr;
rv = false;
} else if (!nochange) {
o.style.color = '000000';
o.innerHTML = objtext;
rv = true;
} else {
rv = true;
}

return rv;
}
var oldUserfile = new Object;
function SetSampImg(imgname, width, height) {
if (imgname) {
oldUserfile.file = document.new_img_frm.userfile.value;
oldUserfile.width = document.new_img_frm.width.value;
oldUserfile.height = document.new_img_frm.height.value;

document.new_img_frm.userfile.disabled = true;
document.new_img_frm.samp_img.value = imgname;
//document.new_img_frm.width.value = width;
//document.new_img_frm.height.value = height;
MM_findObj('imgSampImg').src = "http://www.pixelperks.com/images/pixels/" + imgname;
MM_findObj('divSampImg').style.display = 'block';
MM_findObj('divFile').style.display = 'none';
MM_showHideLayers('lyrSampleImg','','hide');
flag_frm(false, 'userfile', ''); // clear any error description in userfile
} else {
document.new_img_frm.samp_img.value = '';
MM_findObj('divSampImg').style.display = 'none';
MM_findObj('divFile').style.display = 'block';
document.new_img_frm.userfile.disabled = false;
document.new_img_frm.width.value = oldUserfile.width;
document.new_img_frm.height.value = oldUserfile.height;
}

calc_price();
}
function chk_frm() {
var rv = true;

fireChkOverlap();

width=document.new_img_frm.width.value;

height=document.new_img_frm.height.value;

pxprice = 20;

var emlerr = emailCheck(document.new_img_frm.email.value);
rv = flag_frm(emlerr, 'email', emlerr);

rv &= flag_frm(document.new_img_frm.name.value=="", 'name', 'Name cannot be empty');

rv &= flag_frm(document.new_img_frm.displayname.value=="", 'displayname', 'Display Name cannot be empty');

rv &= flag_frm(document.new_img_frm.headline.value=="", 'headline', 'Headline cannot be empty');

rv &= flag_frm(document.new_img_frm.location.value=="", 'location', 'Location cannot be empty');

rv &= flag_frm(document.new_img_frm.x1.value=="" || isNaN(document.new_img_frm.x1.value), 'x1', 'Invalid position');

rv &= flag_frm(document.new_img_frm.y1.value=="" || isNaN(document.new_img_frm.y1.value), 'y1', 'Invalid position');

rv &= flag_frm(document.new_img_frm.title.value=="", 'title', '(cannot be empty)');

uf = document.new_img_frm.userfile.value;
ext = uf.substr(uf.lastIndexOf('.') + 1);
rv &= flag_frm("|gif|jpg|png|jpeg|".indexOf('|' + ext + '|')==-1 && !document.new_img_frm.samp_img.value, 'userfile', 'We only accept GIF, JPEG or PNG pictures');
rv &= flag_frm(uf=="" && !document.new_img_frm.samp_img.value, 'userfile', 'Image file cannot be empty.', true);

errmsg = chk_url(document.new_img_frm.url)
rv &= flag_frm(errmsg, 'url', errmsg);

rv &= flag_frm(!document.new_img_frm.chkRead.checked, 'termscond', 'You must tick the box to continue.');
rv &= calc_price();

if (!rv) {
alert('Please fill in the form correctly.');
return false;
}

return rv;
}
function email_validation(obj) {
if(emailCheck(document.new_img_frm.email.value)==0) obj.style.background="#FFEEEE"; else obj.style.background="#FFFFFF";
}
function DoBtnBuy() {
var pxprice = 20;
var p = new Object;
var ok = IsAreaValid(p) && CheckOffendingZones(p);
if (ok) {
fireChkOverlap();

var amt = CalcZonalPrices(p, ZONES, pxprice);
MM_findObj('price').innerHTML="<b>999"+ amt +"</b>";
document.new_img_frm.amount.value = amt;
MM_findObj('btnBuy').disabled = false;
} else {
MM_findObj('price').innerHTML="Not yet calculated";
MM_findObj('btnBuy').disabled = true;
}

return ok;
}
function IsAreaValid(info) {
var ok = true;
var fields = ['width', 'height', 'x1', 'y1'];
var outfields = ['w', 'h', 'x1', 'y1'];
var values = new Array();

for (i in fields) {
var x = eval("document.new_img_frm." + fields[i] + ".value");
values[fields[i]] = x;
ok &= !(x=="" || isNaN(x) || x != parseInt(x));
}
var x2, y2;

if (ok) {
for (i in fields) {
values[fields[i]] = parseInt(values[fields[i]]);
ok &= !(values[fields[i]] < 0);
}
ok &= !(values['width'] == 0 || values['height'] == 0);
x2 = values['x1'] + values['width'];
y2 = values['y1'] + values['height'];
ok &= !(x2 > 100);
ok &= !(y2 > 100);

document.new_img_frm.x2.value=x2;
document.new_img_frm.y2.value=y2;
}

if (ok && info) {
for (i in fields) {
eval('info.' + outfields[i] + " = " + values[fields[i]]);
}
info.x2 = x2;
info.y2 = y2;
}
return ok;
}
function calc_price() {
var fields = ['width', 'height'];
var coords = ['x1', 'y1'];
var outfields = ['x2', 'y2'];
var val = new Array; // [0 is x1, 1 is y1]
var res = new Array; // [0 is x2, 1 is y2]
var ok = new Array; // [0 is x1's validity, 1 is y1's validity]

for (i in coords) {
var x = eval("document.new_img_frm." + coords[i]).value;
if (flag_frm(x=="" || isNaN(x), coords[i], 'Invalid ' + coords[i])
&& flag_frm(x != parseInt(x), coords[i], 'Cannot accept fraction')
) {
val[i] = parseInt(x);
ok[i] = flag_frm(val[i]<0, coords[i], 'Invalid ' + coords[i]);
ok[i] &= flag_frm(val[i]>=100, coords[i], coords[i] + ' is too big, maximum is 99', true);
}
}

for (i in fields) {
var x = eval("document.new_img_frm." + fields[i]).value;
if (flag_frm(x=="" || isNaN(x), fields[i], 'Invalid ' + fields[i])
&& flag_frm(x != parseInt(x), fields[i], 'Cannot accept fraction')
) {
res[i] = val[i] + parseInt(x);
flag_frm(x<=0, fields[i], 'Invalid ' + fields[i]);
flag_frm(res[i] > 100 && ok[i], fields[i], fields[i] + ' is too big, maximum is ' + (100-val[i]) + ' block(s)', true);
eval('document.new_img_frm.' + outfields[i]).value = res[i];
}
}

return DoBtnBuy();
}
</script>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
<head>
<style>
body {
background: url(images/pagebgnew.jpg) repeat;
}
.white
{
font-family: Verdana;
font-size: 11px;
font-weight: bold;
color: #FFFFFF;
}
.white_every
{
font-family: Verdana;
font-size: 11px;
color: #FFFFFF;
}
a
{
text-decoration: none;
}
.black
{
font-family: Verdana;
font-size: 11px;
font-weight: bold;
color: #000000;
}
.black_no_bold
{
font-family: Verdana;
font-size: 11px;
color: #000000;
}
</style>
<style>
a:hover{color:red}
</style>
<script>
function Init() {
var objn = Array('name', 'email', 'x1', 'y1', 'width', 'height', 'url', 'title', 'userfile', 'termscond', 'displayname', 'headline', 'location');
for (var n in objn) {
origtext[objn[n]] = MM_findObj(objn[n] + '_txt').innerHTML;
}

if (document.new_img_frm.samp_img.value && document.new_img_frm.width.value && document.new_img_frm.height.value)
SetSampImg(document.new_img_frm.samp_img.value, document.new_img_frm.width.value, document.new_img_frm.height.value);
else
DoBtnBuy();
}
</script>
</head>
<body onload="javascript:Init();">
<div id="lyrSampleImg" style="position:absolute; left:694px; top:362px; width:325px; height:248px; z-index:1; visibility: hidden; background-color: #F2F2F2; layer-background-color: #F2F2F2; border: 1px none #000000">
<table width="100%" height="100%" border="1" bgcolor="#F2F2F2" class="smallfnt">
<tr>
<th width="89%" height="24" scope="col"><a href="javascript:;" title="Drag this" onMouseDown="MM_dragLayer('lyrSampleImg','',0,0,0,0,false,false,-1,-1,-1,-1,false,false,0,'',false,'')"> Sample Images</a></th>
<th width="11%" scope="col"><a href="javascript:;" class="whitefnt" title="Close" onClick="MM_showHideLayers('lyrSampleImg','','hide')">X</a></th>
</tr>
<tr valign="top">
<td colspan="2"><p align="center">Click one of the images below to use the image. </p>
<p>
<A HREF='javascript:SetSampImg("ava1x1.jpg", 1, 1);'><img src='images/pixels/ava1x1.jpg' border='0' hspace='1' vspace='1' title='size is 1x1.jpg' /></A>
<A HREF='javascript:SetSampImg("avagirl1x1.jpg", 1, 1);'><img src='images/pixels/avagirl1x1.jpg' border='0' hspace='1' vspace='1' title='size is 1x1.jpg' /></A>
<A HREF='javascript:SetSampImg("bear1x1.gif", 1, 1);'><img src='images/pixels/bear1x1.gif' border='0' hspace='1' vspace='1' title='size is 1x1.gif' /></A>
<A HREF='javascript:SetSampImg("crazy1x1.jpg", 1, 1);'><img src='images/pixels/crazy1x1.jpg' border='0' hspace='1' vspace='1' title='size is 1x1.jpg' /></A>
<A HREF='javascript:SetSampImg("family1x1.gif", 1, 1);'><img src='images/pixels/family1x1.gif' border='0' hspace='1' vspace='1' title='size is 1x1.gif' /></A>
<A HREF='javascript:SetSampImg("insane1x1.gif", 1, 1);'><img src='images/pixels/insane1x1.gif' border='0' hspace='1' vspace='1' title='size is 1x1.gif' /></A>
<A HREF='javascript:SetSampImg("kidding1x1.jpg", 1, 1);'><img src='images/pixels/kidding1x1.jpg' border='0' hspace='1' vspace='1' title='size is 1x1.jpg' /></A>
<A HREF='javascript:SetSampImg("penguin1x1.gif", 1, 1);'><img src='images/pixels/penguin1x1.gif' border='0' hspace='1' vspace='1' title='size is 1x1.gif' /></A>
<A HREF='javascript:SetSampImg("rose1x1.gif", 1, 1);'><img src='images/pixels/rose1x1.gif' border='0' hspace='1' vspace='1' title='size is 1x1.gif' /></A>
<A HREF='javascript:SetSampImg("shin1x1.jpg", 1, 1);'><img src='images/pixels/shin1x1.jpg' border='0' hspace='1' vspace='1' title='size is 1x1.jpg' /></A>
<A HREF='javascript:SetSampImg("violet1x1.jpg", 1, 1);'><img src='images/pixels/violet1x1.jpg' border='0' hspace='1' vspace='1' title='size is 1x1.jpg' /></A>
<A HREF='javascript:SetSampImg("whatver1x1.gif", 1, 1);'><img src='images/pixels/whatver1x1.gif' border='0' hspace='1' vspace='1' title='size is 1x1.gif' /></A>

</p>
</td>
</tr>
</table>
</div>
<table width="1000" border=0 align="center" cellpadding=0 cellspacing=0>
<tr>
<td width=211 background="images/grid.gif" style="border-left: 1px solid #423837;">&nbsp;</td>
<td width=576 bgcolor=#EFEFEF>
<form name="new_img_frm" method="post" action="paypal_confirm.php" enctype="multipart/form-data" onSubmit="javascript:return chk_frm();">
<p>
<input type=hidden name=x2>
<input type=hidden name=y2>
</p>
<p>&nbsp;</p>
<table border=1 cellspacing=0 cellpadding=4 align=center>
<tr>
<td bgcolor=#000077 class=whitefnt align=center><h2>Buy Pixel Block
Advertisement </h2></td>
</tr>
<tr>
<td background="images/bg.gif"> <table class=smallfnt cellspacing=6>
<tr>
<td width="150">Area:</td>
<td width="200">&nbsp;</td>
</tr>
<tr>
<td><span id='x1_txt'>&nbsp;&nbsp;x1 Position</span></td>
<td>
<input name="x1" type="text" onBlur="calc_price()" onChange="calc_price()" value="17"></td>
</tr>
<tr>
<td><span id='y1_txt'>&nbsp;&nbsp;y1 Position</span></td>
<td>
<input name="y1" type="text" onBlur="calc_price()" onChange="calc_price()" value="3"> </td>
</tr>
<tr>
<td><span id="width_txt">&nbsp;&nbsp;Width</span></td>
<td><input name='width' type='text' onBlur="calc_price()" onChange="calc_price()" value="1">
block(s)<br>
1 block = 40 pixels. </td>
</tr>
<tr>
<td><span id="height_txt">&nbsp;&nbsp;Height</span></td>
<td><input name='height' type='text' onBlur="calc_price()" onChange="calc_price()" value="1">
block(s)<br>
1 block = 40 pixels.</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td><span id="name_txt">Business Name (Enter your name if no business)</span></td>
<td><input type=text name=name></td>
</tr>
<tr>
<td><span id="url_txt">Link to website (If none, you can choose your Facebook page.)</span></td>
<td><input name=url type=text onChange="chk_url(this)" value="http://"></td>
</tr>
<tr>
<td><span id='displayname_txt'>Contact Name</span></td>
<td><input name=displayname type=text></td>
</tr>
<tr>
<td><span id='headline_txt'>Business Slogan</span></td>
<td><input name=headline type=text></td>
</tr>
<tr>
<td><span id='location_txt'>Location</span></td>
<td><input name=location type=text></td>
</tr>
</tr>

<tr>
<td><span id="title_txt">Describe your site (50 characters)</span></td>
<td><input name=title type=text></td>
</tr>
<tr>
<td valign="top"><span id="userfile_txt">Pixel(s) Image</span></td>
<td><span id='divFile' style="display:block;">
<input name="userfile" type="file" id="userfile" accept="image/gif,image/jpeg,image/x-png,image/png">
<br>

<input name="samp_img" type="hidden" value="">
</span>
<span id='divSampImg' style="display:none;">
<img id='imgSampImg' /> <a href="javascript:SetSampImg('');">Delete</a>
</span>
</p></td>
</tr>
<tr>
<td height=30>Price</td>
<td>USD<input type="hidden" name="amount"> <span id=price><b>20<b></span></td>
</tr>
<tr>
<td height=30 colspan="2">
<input name="chkRead" type="checkbox" id="chkRead" value="1">
<span id="termscond_txt">
By ticking this box, I accept this website's <a href="howtobuy.php#termscond" target="_termscond">terms and conditions</a> of sales.</span></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<input name="btnBuy" type=submit id="btnBuy" value="Preview &amp; checkout">
<input type=reset value="Reset"></td>
</tr>
</table></td>
</tr>
</table>
</form>
<div align="center">
<p> </H2>
</p>
</div></td>
<td width="211" background="images/grid.gif" style="border-right: 1px solid #423837;">&nbsp;</td>
</tr>
</table>
<script>Tip_WriteObj();</script>
<div align="center" style="margin-top:0">
<table border="0" width="1000" cellpadding="5" cellspacing="0">
<tr>
<td height=28 align="center" bgcolor="#10398C">
<font size=1 color=#FFFFFF face=verdana>
<br>

VIPStephan
12-01-2012, 08:38 PM
If you post any code please clean it up/format it a little so it’s easier to read and then put it in between
tags. It makes scanning your posts much easier. You can do this by clicking the small ‘#’ icon above the reply field.

nest9
12-01-2012, 09:01 PM
Sorry for that. Thank you for the help.

Dormilich
12-02-2012, 11:56 AM
origtext is not available in the scope concerned and function Tip_WriteObj() doesn’t exist.

Old Pedant
12-03-2012, 07:35 AM
I'm not so sure about origtext.

There is never any var declaration for it, so presumably it is thus automatically a global (page scope).

But of course the real problem with all this code is that it is at least partially generated by DrunkWalking (misnamed "DreamWeaver" by the authors). I would never trust any code that DoofusWhomper created.

I mean just look at that:

function MM_reloadPage(init) { //reloads the window if Nav4 resized

Nav4 means "Netscape Navigator version 4". A product that *DIED* about 12 years ago. Dead. Gone. Maybe 3 people in the world still use it?

And you *know* that DingleWimper's MM_findObj code is similarly obsolete.

Anyway, clearly we are not being shown *ALL* the code, because the DuckWhacker code for MM_findObj is not there, so who knows what else has been omitted?

rnd me
12-03-2012, 08:10 PM
i got lost looking for the blue text but the problem with the red text is that it searches for body objects from the head, before they appear. the code should go at the bottom of the page, just inside </body>. or in the circular file...

not sure why CreamJeaner would put them in the head.

Old Pedant
12-03-2012, 09:08 PM
not sure why CreamJeaner would put them in the head.

LOL! Another great alias! Anyway, NightmareStalker is basically 15 years old and has had virtually no improvements in all that time. (This is at least true for its JS code generation, but seeing how it still lays everything out using many nested <table>s one has to think it's true of most all the stuff it generates.)

And, of course, 15 years ago nobody ever put JS anyplace except in the <head>.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum