Web Analytics Made Easy -
StatCounter Problem with prompt box.... - CodingForum

Announcement

Collapse
No announcement yet.

Problem with prompt box....

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem with prompt box....

    I have this code:


    PHP Code:
    ffunction getName(nm) {
      
    userName nm;
      
    msg.close();
      
    now = new Date();
      
    exp = new Date(Date.parse(now) + (86400000*365));
      
    SetCookie("userName"userNameexp);
      
    window.location.reload();
    }

    function 
    askUserName() {
      
    msg window.open("","msg","top=500,left=500,height=100,width=300,dependent=yes,resizable=yes");
      
    msg.focus();
      
    msg.document.writeln("<body onLoad='document.f1.nm.focus()'>");
      
    msg.document.writeln("<form name='f1' onSubmit='window.opener.getName(this.nm.value);return false'>");
      
    msg.document.writeln("<table>");
      
    msg.document.writeln("<tr>");
      
    msg.document.writeln("<td>Please enter your name: </td>");
      
    msg.document.writeln("<td><input name='nm' type='text'></td>");
      
    msg.document.writeln("</tr>");
      
    msg.document.writeln("<tr>");
      
    msg.document.writeln("<td>&nbsp;</td>");
      
    msg.document.writeln("<td><input type='submit' onsubmit='id()' value=' Submit '></td>");
      
    msg.document.writeln("</tr>");
      
    msg.document.writeln("</table>");
      
    msg.document.writeln("</body>");
      
    msg.document.close();
      return 
    false;
    }

    function 
    getCookieVal(offset) {
      var 
    endstr document.cookie.indexOf (";"offset);
      if (
    endstr == -1)
        
    endstr document.cookie.length;
      return 
    unescape(document.cookie.substring(offsetendstr));
    }

    function 
    SetCookie(name,value,expires,path,domain,secure) {
      
    document.cookie name "=" escape (value) +
        ((
    expires) ? "; expires=" expires.toGMTString() : "") +
        ((
    path) ? "; path=" path "") +
        ((
    domain) ? "; domain=" domain "") +
        ((
    secure) ? "; secure" "");
    }

    function 
    GetCookie(name) {
      var 
    arg name "=";
      var 
    alen arg.length;
      var 
    clen document.cookie.length;
      var 
    0;
      while (
    clen) {
        var 
    alen;
        if (
    document.cookie.substring(ij) == arg)
          return 
    getCookieVal(j);
        
    document.cookie.indexOf(" "i) + 1;
        if (
    == 0) break; 
      }
      return 
    null;
    }

    userName GetCookie("userName");
    if (!
    userName
      {
    askUserName();}

    function 
    checkUser() {
      if (
    document.getElementById)
        {if (
    userNamedocument.getElementById("empinfo").style.visibility "visible";}
      else {
        if (
    document.layers)
          {if (
    userNamedocument.empinfo.visibility "visible";}
        else
          {if (
    userNamedocument.all.empinfo.style.visibility "visible";}
      }
    }

    function 
    id(){
        
        
         
    document.forms.empinfo.emplname.value askUserName();
                    

    It has a pop up that asks for a user name, then sets that name as a cookie. That part works.

    I am trying to get it to pass that information to the main form,
    "empinfo", then to an input box, "emplname".


    but it doesn't seem to work.

    I have this function:

    PHP Code:
    function id(){
             
    document.forms.empinfo.emplname.value userName();
                    

    which I was hoping would do the trick. but it isn't working.

    can anyone help me ???

    Thanks for your help....

    james

  • #2
    I'm a little confused. You point to two different functions name "id" -- which one is correct, or do actually have both with the same name?

    Also, in your 2nd code snippet, you call userName as a function, when you have no function with the name (but, it is a variable)
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

    Comment


    • #3
      huh?

      So your trying to use cookies to remember a username and password for the form, then when the browser reloads, the username and password will be stored in the cookies, therefore automaticly logged in...? I have no idea...



      digicm
      ?


      digicam

      Comment


      • #4
        this is what I was suppose to have:


        PHP Code:
        function id(){
            
            
             
        document.forms[empinfo].emplname.value userName;
                        

        Yes, that is right, the first id is set here:
        PHP Code:
        msg.document.writeln("<form name='f1' onSubmit='window.opener.getName(this.nm.value);return false'>"); 

        That form name is for the pop up window asking for the users Name.

        that name is set in the cookie: userName.

        I am trying to get that passed to another form.


        the id for that form is:

        empinfo

        and I have the input box that I want it to be passed to label as:

        emplname.


        Does this help any ????
        Last edited by jrmevans; Feb 28, 2004, 06:29 PM.

        Comment


        • #5
          dunno. i only know the basics of html... srry




          digicm
          ?


          digicam

          Comment

          Working...
          X