Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 11-05-2004, 09:24 AM   #1 (permalink)
buchannon
Registered User
 
buchannon's Avatar
 
Join Date: Nov 2004
Posts: 43
buchannon is on a distinguished road
Cookies...

Ok I had a post in here about changing the font size of a document, and I finally got it working, now I'm trying to store and unload that value into a cookie for when the user comes back it will remain the same size font. I'm totally new to all this so whatever help you guys can give me would help. So far I have:

Quote:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<title>Test</title>
<script type="text/javascript">

function changeSize(size)
{
var date = new Date("December 31, 2023");
var the_date = date.toGMTString();
var the_size = "sizecookie=" + size +";expires=" + the_date;
document.cookie = the_size;
//cookie saved as sizecookie=xxpx;expires=December 31, 2023

//Starts unloading cookie
var csize = document.cookie;
var csize = csize.split("=");
var csize = csize[1];
var csize = csize.split(";");
var csize = csize[0];

document.getElementById('test').style.fontSize = csize;
document.getElementById('tabletest').style.fontSiz e = csize;
}//changeSize


</script>
</head>

<body>
<form>
<select title="Select a Font Size" name="FontSize" id="FontSize" style="width:75px" class="layoutMenu">
<option value="10px">10px</option>
<option value="11px">11px</option>
<option value="12px" selected>12px</option>
<option value="13px">13px</option>
<option value="14px">14px</option>
<option value="15px">15px</option>
<option value="16px">16px</option>
<option value="17px">17px</option>
<option value="18px">18px</option>
<option value="19px">19px</option>
<option value="xx-large">extra Large</option>-->
</select>

<input type="button" onclick="changeSize(document.getElementById('FontS ize').value);" value="GO TO IT!">
</form>

<div id="test">
Here is some text
<br>

<br>
Here is some text


<table id="tabletest"><tr><td>did it work on me?</td></tr><tr><td>How about me?</td></tr></table>


</div>

</body>
</html>
buchannon is offline   Reply With Quote
Old 11-05-2004, 09:34 AM   #2 (permalink)
Admin
$_['Your_Mom'];
 
Admin's Avatar
 
Join Date: May 2002
Location: Santee
Posts: 627
Admin is on a distinguished road
It would be much nicer to use a server side scripting language (PHP perhaps?) to handle this.
__________________


Urban Clothing
Admin is offline   Reply With Quote
Old 11-05-2004, 09:47 AM   #3 (permalink)
buchannon
Registered User
 
buchannon's Avatar
 
Join Date: Nov 2004
Posts: 43
buchannon is on a distinguished road
I guess I could get into that... I always have heard that JS stuff was way easier than server side scripting thought. Plus I have a tiny bit of JS experience where I don't know a thing about cgi.
buchannon is offline   Reply With Quote
Old 11-05-2004, 10:32 AM   #4 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,475
sde is on a distinguished road
hey buchannon, .. the syntax of php is a lot like javascript, so it probably wouldn't be that difficult to pick it up. there's tons of support for php all over the internet, and you'de probably get quite a bit of help right here too.

here is the reason .. anyone can turn javascript off in their browsers .. since javascript runs on the client, there are way to many things that can go wrong.

when you use a server-side languge, it will run the same no matter who is accessing it. that and you have a LOT more power over everything from string manipulation to hard-core socket programming if you wished to get that deep.

here is how easy it is to set cookies in php:
PHP Code:
<?
$value 
'something from somewhere';
setcookie("TestCookie"$valuetime()+3600);  /* expire in 1 hour */
?>
<html>
<body>
... the rest of your web page here ..
and here is how you would print cookie info to the browser:
PHP Code:
<html>
<body>
the value of my cookie is: <?=$_COOKIE['TestCookie']?>
__________________
Mike
sde is offline   Reply With Quote
Old 11-05-2004, 12:09 PM   #5 (permalink)
buchannon
Registered User
 
buchannon's Avatar
 
Join Date: Nov 2004
Posts: 43
buchannon is on a distinguished road
ok I just read up on PHP and was getting excited about it (the power of it) but was just told that the school servers where I work don't support php because it's a "vulnerability." So I'm back to JS I guess... Thanks for the suggestion though!
buchannon is offline   Reply With Quote
Old 11-05-2004, 12:20 PM   #6 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,475
sde is on a distinguished road
hah, i wish they would have explained exactly what 'vulnerability' it is. if they are running a current version, and have safe mode enabled, there really isn't much one can do to the servers... otherwise every hosting company who allowed php ( including mine ) would be in trouble.

you can always install it locally and develop like that .. or get web space somewhere.
__________________
Mike
sde is offline   Reply With Quote
Old 11-05-2004, 12:25 PM   #7 (permalink)
buchannon
Registered User
 
buchannon's Avatar
 
Join Date: Nov 2004
Posts: 43
buchannon is on a distinguished road
I currently work for a college. I don't know if it would be... polite of me to change settings and stuff if they don't want them.

How hard would it be to just install php support on one directory of the server anyway? Would that be a free download?
buchannon is offline   Reply With Quote
Old 11-05-2004, 12:34 PM   #8 (permalink)
buchannon
Registered User
 
buchannon's Avatar
 
Join Date: Nov 2004
Posts: 43
buchannon is on a distinguished road
And I still don't understand why that JS code isn't working if anyone can help with that also... Thanks guys
buchannon is offline   Reply With Quote
Old 11-05-2004, 12:34 PM   #9 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,475
sde is on a distinguished road
well PHP is open source and free: http://php.net/ It can be installed with IIS (windows web server) or Apache. It does however need to be configured on the web server itself.

Do they use any server-side programming language? I understand about being polite, but it's probably also in their best interest to consider such technology. It will help in terms of development efficiency and allow them to do a lot more with web applications.

I don't know if you code outside of work, but it would definately be worth installing and playing around with it on your local pc to see what kind of power it gives you.
__________________
Mike
sde is offline   Reply With Quote
Old 11-05-2004, 12:37 PM   #10 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,475
sde is on a distinguished road
sorry i can't help with the js cookies, .. never used js for that =/
__________________
Mike
sde is offline   Reply With Quote
Old 11-05-2004, 12:38 PM   #11 (permalink)
buchannon
Registered User
 
buchannon's Avatar
 
Join Date: Nov 2004
Posts: 43
buchannon is on a distinguished road
I really am interested in playing around with it now, I always considered PHP on the same level as pearl in that it was stinking hard. I realize it's no cakewalk or anything but it looks like something I could start learning right now.

I just sent another e-mail to the web admin to ask if any SS programming (is this the same thing as CGI) is supported but I have a feeling that Java will be it.
buchannon is offline   Reply With Quote
Old 11-05-2004, 12:51 PM   #12 (permalink)
Redline
PHP Student
 
Join Date: Oct 2004
Location: Forest Grove, OR
Posts: 150
Redline is on a distinguished road
Send a message via AIM to Redline Send a message via MSN to Redline
You should be able to pick up PHP pretty quick. It's really not a hard language. I taught myself enough PHP to build my clans website with it in a month and half. And that's after not doing ANY sort of programming for 3 years or so :rock:
__________________
Current Project
Redline is offline   Reply With Quote
Old 11-05-2004, 01:03 PM   #13 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,475
sde is on a distinguished road
php is a lot more friendly than perl. server-side is pretty much like CGI/Perl in comparison, although CGI is not the only way to run server-side languages.
__________________
Mike
sde is offline   Reply With Quote
Old 11-05-2004, 01:08 PM   #14 (permalink)
buchannon
Registered User
 
buchannon's Avatar
 
Join Date: Nov 2004
Posts: 43
buchannon is on a distinguished road
hm... I'll play around with this JS a little bit more. I take it from what you are telling me that JS is not really used for much more than form validation and little effects these days because languages like PHP are much more powerful and easy to impliment?

PS: Nice site Redline!
buchannon is offline   Reply With Quote
Old 11-05-2004, 01:36 PM   #15 (permalink)
Redline
PHP Student
 
Join Date: Oct 2004
Location: Forest Grove, OR
Posts: 150
Redline is on a distinguished road
Send a message via AIM to Redline Send a message via MSN to Redline
Quote:
I take it from what you are telling me that JS is not really used for much more than form validation and little effects these days because languages like PHP are much more powerful and easy to impliment?
That about sums it up I think. I'm learning javascript right now though. Before last night I knew nothing of it. But yes, it's pretty easy to harness the power of PHP if you have any sort of programming background.

This will be your greatest resource for PHP information, I know it was mine... http://www.php.net/manual/en/

Quote:
PS: Nice site Redline!
Thanks! The design isn't mine, it was done by another clan member. Basically he did one page pure HTML and I cut it up, coded, and created the rest of the site behind it.
__________________
Current Project
Redline is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
cookie users across sub-domains? sde PHP 5 08-25-2004 02:08 PM
Cookies Problems rdove Feedback 2 02-17-2003 07:29 PM


All times are GMT -8. The time now is 10:10 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting