CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignCSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 30th, 2003, 10:27 PM
dmonk dmonk is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 22 dmonk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Smile changing css style color with switch

Ok, this should be easy for you guys here.

This is what I'm trying to do :

-create a recursive page

-page contains 3 radio buttons

-buttons allow for choice between colors: green, blue, red.

-default choice is green font color (css style)

-form should remember the selected choice (the rest of the page performs some addition problems)

-can't use cookies only the switch function to change the font color (css style)

-no external css files

Here's what I have. I know I'm making some mistakes, just don't know how to fix them.


Thank you.


-----------------
The second part of my question is of low priority :

What's the best text editor to use for the Mac? I was using BBEDIT and began to see some weird characters on some servers.

Are there any text editors that color the text (different colors for diff. attributes) and also show line#'s (for the mac osx?)


-----------------clipping starts here----------------

<html>
<head>
<title></title>
<body style="font-family:Arial, Helvetica, sans-serif; color: green;">
</table>
<tr>
<td>
<form name="stylecolor" method=POST" action asgn_2j.php">

Green
<input type="radio" name="style" value="green">

Blue
<input type="radio" name="style" value="blue">

Red
<input type="radio" name="style" value="red">

<INPUT TYPE=HIDDEN NAME=stylecolor VALUE=true>

<INPUT TYPE=submit NAME="SUBMIT" VALUE="Submit">

<?
$stylecolor=$HTTP_POST_VARS['stylecolor'];

switch($stylecolor)
{
case 'green
echo '(<body style="font-family:Arial, Helvetica, sans-serif; color: green;">)' ;

case 'blue'
echo '(<body style="font-family:Arial, Helvetica, sans-serif; color: blue;">)' ;

case 'red'
echo '(<body style="font-family:Arial, Helvetica, sans-serif; color: red;">)' ;

default:
echo 'you didn't choose' ;
break;

}
?>
</form>
</td>
</tr>
</table>
</body>
</html>

Reply With Quote
  #2  
Old July 1st, 2003, 12:23 AM
micros_bytes micros_bytes is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Oct 2002
Posts: 790 micros_bytes User rank is Corporal (100 - 500 Reputation Level)micros_bytes User rank is Corporal (100 - 500 Reputation Level)micros_bytes User rank is Corporal (100 - 500 Reputation Level)micros_bytes User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 10 h 29 m 56 sec
Reputation Power: 10
dmonk,

There's no need to use a switch structure to do what you want to do. There were a few problems with your code. Take a look at the modified code below and compare to your code to see the changes that were made. Hopefully, that will explain a few things.

I'm not sure what you were trying to do with the hidden field but it looks like that's what you were trying to evaluate in your switch. However, you should be checking the value of the radio buttons. Putting [] after the name of the radio buttons makes PHP view them as an array. Since they are radio buttons, only one is going to have a value set so all you need to evaluate is the first element of the style array ( $_POST['style'][0]) to get the selected color.

The if(isset($_POST['style']) checks to see if the form has been submitted. If it has then the value of the selected radio button is used for the style color. If the form has not been submitted, the default color is used (the else{}) portion of the code.

Hope this all makes sense and helps out a bit.

PHP Code:
<html>
<
head>
<
title></title>
</
head>
<?
php
if(isset($_POST['style'])){
$stylecolor=$_POST['style'][0];
echo 
"<body style='color:$stylecolor'>";
}
else
{
    echo 
"<body style='color:green'>";
}
?>

</table>
<tr>
<td>
<form name="stylecolor" method="POST" action="asgn_2j.php">

Green
<input type="radio" name="style[]" value="green">

Blue
<input type="radio" name="style[]" value="blue">

Red
<input type="radio" name="style[]" value="red">

<INPUT TYPE=submit NAME="SUBMIT" VALUE="Submit">

</form>
</td>
</tr>
</table>
</body>
</html> 

Reply With Quote
  #3  
Old July 2nd, 2003, 01:38 AM
dmonk dmonk is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 22 dmonk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks

Than you for the help micros_bytes, I'll give it a try.

-Dan

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignCSS Help > changing css style color with switch


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT