What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » javascript POST?

javascript POST?
Author: Message:
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: javascript POST?
No, you don't need a form to do what you want I think. Unless you can't popup an inputbox with PHP to get a name from the user. I don't know PHP. It was just an workflow idea how you could do it in pure javascript, which you can convert to PHP I thought. But you need a function in PHP where you can popup an inputbox for it to work...


Here is the javascript version of it. This time I tested it, and as you can see, not much had to be changed (only had to add [1] and replace "" with null):
code:
<html>

  <head>
    <title>Main Page</title>
    <script language="JavaScript">
      function GetName() {
        var username = unescape(document.cookie)
        username = username.split("=")[1]
        if (username == null) {
          username = prompt("What is your name?","")
          var expiredate = new Date()
          expiredate.setMonth(expiredate.getMonth() + 1)
          document.cookie = "Name=" + username + ";expires=" + expiredate.toGMTString() + ";path=/"
        }
        return username
      }
      function ClearName() {
        var expiredate = new Date()
        document.cookie = "Name=;expires=" + expiredate.toGMTString() + ";path=/"
      }
    </script>
  </head>

  <body onLoad="javascript:alert(GetName() + ', welcome...');">
    <input type="button" value="Clear cookie..." onClick="ClearName()">
    <br>main page
  </body>

</html>
So this is the concept, I guess. I'm sure this can be done in PHP also, but instead of cookies, use a database... BTW, this is only a very crude example.


PS: about the semicolons, you don't need them in javascript. But it is indeed a good habbit to put them there...

.zip File Attachment: poc.zip (514 bytes)
This file has been downloaded 279 time(s).

This post was edited on 02-21-2004 at 08:22 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
02-21-2004 08:12 AM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
javascript POST? - by bach_m on 02-20-2004 at 03:02 AM
RE: javascript POST? - by WDZ on 02-20-2004 at 04:32 AM
RE: javascript POST? - by fluffy_lobster on 02-20-2004 at 09:31 AM
RE: javascript POST? - by CookieRevised on 02-20-2004 at 10:55 AM
RE: javascript POST? - by KeyStorm on 02-20-2004 at 11:57 AM
RE: javascript POST? - by bach_m on 02-20-2004 at 12:04 PM
RE: javascript POST? - by CookieRevised on 02-20-2004 at 01:41 PM
RE: javascript POST? - by KeyStorm on 02-20-2004 at 02:45 PM
RE: javascript POST? - by WDZ on 02-20-2004 at 03:39 PM
RE: javascript POST? - by KeyStorm on 02-20-2004 at 04:19 PM
RE: javascript POST? - by WDZ on 02-20-2004 at 05:10 PM
RE: javascript POST? - by KeyStorm on 02-20-2004 at 05:13 PM
RE: javascript POST? - by bach_m on 02-20-2004 at 08:21 PM
RE: javascript POST? - by CookieRevised on 02-20-2004 at 09:25 PM
RE: javascript POST? - by bach_m on 02-20-2004 at 11:20 PM
RE: javascript POST? - by CookieRevised on 02-21-2004 at 08:12 AM
RE: javascript POST? - by KeyStorm on 02-21-2004 at 12:33 PM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On