...

View Full Version : help in jscript error!



imsodarnpretty
07-23-2002, 07:40 AM
this code is supposed to validate first if there is a value on the retrieved txtbox value...and if there is a value, it will be stored on a cookie and submit the form to a pop up window:

<SCRIPT LANGUAGE="JavaScript">
<!--
cookie_name = "dataCookie";
var YouEntered;
var expireDate = new Date();
expireDate.setMonth(expireDate.getMonth() + 1);
window.name = "mymainwindow";

function passData(data)
{
if (document.formcookie.emailadd.value == "") alert ("Please enter an email address!")
else
{ YouEntered=document.formcookie.emailadd.value;
document.write(document.cookie)=cookie_name+"="+YouEntered+";expires=" + expireDate.toGMTString();
windowHandle = window.open('ecard_email_detect.asp' + '?' + data,'windowName','resizable=no,width=520,height=250');
return true;
}
}
//-->
</SCRIPT>

and this code triggers it:

<form name="formcookie" method="post" action="ecard_email_detect.asp" target="newWindow" onSubmit="return false">
<input type="text" name="emailadd" size="20">
<INPUT TYPE="submit" class="button" VALUE="Subscribe" onClick="passData(this.form.emailadd.value);" name="Submit">
</form>

but everytime i test it, it says 'type mismatch return' and its on line 287 (but i only have till line 278)...ive been debugging it but no success...

mordred
07-23-2002, 09:49 AM
You had an error near where you tried to document.write() the cookie. I guess you rather wanted to write the new value to the cookie, and for this you don't employ document.write().



function passData(data)
{
if (document.formcookie.emailadd.value == "") {
alert ("Please enter an email address!");
} else {
YouEntered=document.formcookie.emailadd.value;
document.cookie = cookie_name +"=" + YouEntered+";expires=" + expireDate.toGMTString();
windowHandle = window.open('ecard_email_detect.asp' + '?' + data,'windowName','resizable=no,width=520,height=250');
return true;
}
}


The code above then worked fine for me.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum