form menu style sheet changer

Reply

Join Date: Jul 2006
Posts: 1,091
Reputation: MattEvans is a jewel in the rough MattEvans is a jewel in the rough MattEvans is a jewel in the rough 
Solved Threads: 63
Moderator
Featured Poster
MattEvans's Avatar
MattEvans MattEvans is offline Offline
Veteran Poster

Re: form menu style sheet changer

 
0
  #11
Jan 26th, 2007
Oops; the problem is that that code is self-restricting.

Any value in the cookie overrides the value from the form; so, once you submit once, you can't submit again.

Corrected part: (ASP only)
<%@ LANGUAGE="JAVASCRIPT" %>
<% var style = new String(Request.Form('style'));
if(style==null || style==''){
  style = new String(Request.Cookies('style'));
  if(style==null || style==''){
   style="default";
  }
}else{
   Response.Cookies('style') = style;
}
%>

Seems like a minor thing, but it'll make all the difference =P
Last edited by MattEvans; Jan 26th, 2007 at 7:13 pm.
Plato forgot the nullahedron..
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 203
Reputation: MaxMumford is an unknown quantity at this point 
Solved Threads: 2
MaxMumford's Avatar
MaxMumford MaxMumford is offline Offline
Posting Whiz in Training

Re: form menu style sheet changer

 
0
  #12
Jan 27th, 2007
yay it works!! the only thing is the cookie isnt working. i have added a second page to the folder and the 2 pages link to eachother so as to test the asp cookie however its not working. Also, how do you make the default style sheet be styles_1.css? Thanks,

Max
Ill solve somebody's thread someday! xD
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 1,091
Reputation: MattEvans is a jewel in the rough MattEvans is a jewel in the rough MattEvans is a jewel in the rough 
Solved Threads: 63
Moderator
Featured Poster
MattEvans's Avatar
MattEvans MattEvans is offline Offline
Veteran Poster

Re: form menu style sheet changer

 
0
  #13
Jan 27th, 2007
hmmm, i had a quick visit to your page (from that link) with cookies cleared and cookie notifications switched on. The first event is a request to set the style cookie to 'undefined':

HTML and CSS Syntax (Toggle Plain Text)
  1. This page wishes to set the cookie
  2. style="undefined"
  3.  
  4. This value will only be sent to documents on the server grafax.co.uk, and paths that are starting in /.
  5.  
  6. The cookie will be deleted when Opera is closed.
  7. ----------------------
  8. Full cookie request:
  9.  
  10. style=undefined; path=/

So, that means the if(style==null || style='undefined') checks were probably correct... it's a bit weird that O_o. Go with a full test just in case:

<%@ LANGUAGE="JAVASCRIPT" %>
<% var style = new String(Request.Form('style'));
if(style==null || style=='undefined' || style==''){
  style = new String(Request.Cookies('style'));
  if(style==null || style=='undefined' || style==''){
   style="1";
  }
}else{
   Response.Cookies('style') = style;
}
%>

the line in blue is where you should define the default stylesheet's filename suffix, so a '1' will make the default sheet /styles/style_1.css.
Last edited by MattEvans; Jan 27th, 2007 at 6:46 pm.
Plato forgot the nullahedron..
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 203
Reputation: MaxMumford is an unknown quantity at this point 
Solved Threads: 2
MaxMumford's Avatar
MaxMumford MaxMumford is offline Offline
Posting Whiz in Training

Re: form menu style sheet changer

 
0
  #14
Jan 28th, 2007
Yay it works!

2 more things.. how do you make it so when you select a new style sheet for the pages it goes there automatically when you press it, rather than having to press the submit button?

Also, how can i make it so the selected option is the style sheet being used? for example, if style sheet 2 was being used, option 2 in the menu would be selected?


Thanks,

Max
Ill solve somebody's thread someday! xD
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the HTML and CSS Forum
Thread Tools Search this Thread



Tag cloud for HTML and CSS
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC