Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jul 2002
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry help in jscript error!

    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...

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: help in jscript error!

    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().

    Code:
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •