Minimeallolla Posted February 17, 2011 Share Posted February 17, 2011 Can someone help explain to me how I would go about embedding a javascript clock/time function code into a html submit form? Ok so this cookie asks for a username through a pop up on connection, I would rather use the information submitted by a username form instead and use it as a php cookie. // COOKIE FUNCTION STARTS HERE \\ function getCookie(c_name) { var i,x,y,ARRcookies=document.cookie.split(";"); for (i=0;i<ARRcookies.length;i++) { x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("=")); y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1); x=x.replace(/^\s+|\s+$/g,""); if (x==c_name) { return unescape(y); } } } function setCookie(c_name,value,exdays) { var exdate=new Date(); exdate.setDate(exdate.getDate() + exdays); var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString()); document.cookie=c_name + "=" + c_value; } function checkCookie() { var username=getCookie("username"); if (username!=null && username!="") { alert("Welcome again " + username); } else { username=prompt("Please enter your name:",""); if (username!=null && username!="") { setCookie("username",username,365); } } } // COOKIE FUNCTION STOPS HERE \\ Link to comment https://forums.phpfreaks.com/topic/227967-embedding-javascript-code-into-html-code-someone-help-explain-how-i-would-modify/ Share on other sites More sharing options...
jcanker Posted February 18, 2011 Share Posted February 18, 2011 Do you mean you just want to have a timestamp of the time that the user submitted the form? I'd handle that on the server side when the form is submitted. Otherwise, if you need to get the date/time, it depends on what format you need, and there's 100 ways to skin a cat. The basic premise is simple: new Date().getTime(); Will return the timestamp in UNIXTIME format which is nice and easy to do date/time calculations with Link to comment https://forums.phpfreaks.com/topic/227967-embedding-javascript-code-into-html-code-someone-help-explain-how-i-would-modify/#findComment-1175952 Share on other sites More sharing options...
Minimeallolla Posted February 18, 2011 Author Share Posted February 18, 2011 ): I mean't cookie/username not clock/time lol it was really late. Dont worry, I have abandon this and have started other things lol Link to comment https://forums.phpfreaks.com/topic/227967-embedding-javascript-code-into-html-code-someone-help-explain-how-i-would-modify/#findComment-1176017 Share on other sites More sharing options...
jcanker Posted February 18, 2011 Share Posted February 18, 2011 lol..that's fine For the record: Send the info to the php via POST and on the php side, set it as a $_SESSION variable and use that via AJAX Link to comment https://forums.phpfreaks.com/topic/227967-embedding-javascript-code-into-html-code-someone-help-explain-how-i-would-modify/#findComment-1176021 Share on other sites More sharing options...
Minimeallolla Posted February 18, 2011 Author Share Posted February 18, 2011 Yeah, i'll stick to using php since the way I intended on using javascript wasn't really interactive, more server like. Link to comment https://forums.phpfreaks.com/topic/227967-embedding-javascript-code-into-html-code-someone-help-explain-how-i-would-modify/#findComment-1176064 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.