Page 1 of 1

some questions on CSS and Javascript

Posted: Sun Oct 12, 2003 12:34 am
by m3rajk
i'm trying to get a page made to help users with finding RGB and Hexadecimal color codes to become XHTML compliant instead of HTML 4.01
i created a variant to play aroundon. i thought i found the solution, but when i switched from http://24.91.157.113/findyourdesire/colorfinder.php to http://24.91.157.113/findyourdesire/vcf.php i got javascript issues. i don't understand what in the change caused that

incase you look at this at a time the server is off (my rents have a habit of turning it off on me :x ), here's the two sets of javascript (where the differences are, not the entire code):
working:

Code: Select all

<script language="javascript">
function findcolor()&#123; // find the colors
  
  /* find out what was entered */
  var hdp=(parent.cntrl.document.colortable.hdp.value);
  var red=(parent.cntrl.document.colortable.red.value *1);
  var gre=(parent.cntrl.document.colortable.green.value *1);
  var blu=(parent.cntrl.document.colortable.blue.value *1);
  var hred=parent.cntrl.document.colortable.red.value;
  var hgre=parent.cntrl.document.colortable.green.value;
  var hblu=parent.cntrl.document.colortable.blue.value;
  var text="style="color:#ffffff"";
  var hexpat=/^&#1111;0-9A-Fa-f]+$/; // any valid hex character one or more times
  var pat=/^&#1111;C-Fc-f]&#1111;0-9A-Fa-f]$/; // anything lighter than bf
  
  function writeframe(r, g, b, text)&#123; // write to the frames;
    
    parent.b1.document.open(); // write red
    parent.b1.document.write("<html><body bgcolor="#"+r+"0000" "+text+"> \n Color=#"+r+"0000 \n </body></html>");
    parent.b1.document.close();
    
    parent.b2.document.open(); // write yellow
    parent.b2.document.write("<html><body bgcolor="#"+r+g+"00" "+text+"> \n Color=#"+r+g+"00 \n </body></html>");
    parent.b2.document.close();
    
    parent.b3.document.open(); // write green
    parent.b3.document.write("<html><body bgcolor="#00"+g+"00" "+text+"> \n Color=#00"+g+"00 \n </body></html>");
    parent.b3.document.close();
    
    parent.c.document.open(); // write full color
    parent.c.document.write("<html><body bgcolor="#"+r+g+b+"" "+text+"> \n Color=#"+r+g+b+" \n </body></html>");
    parent.c.document.close();
      
    parent.d1.document.open(); // write magenta
    parent.d1.document.write("<html><body bgcolor="#"+r+"00"+b+"" "+text+"> \n Color=#"+r+"00"+b+" \n </body></html>");
    parent.d1.document.close();
    
    parent.d2.document.open(); // write blue
    parent.d2.document.write("<html><body bgcolor="#0000"+b+"" "+text+"> \n Color=#0000"+b+" \n </body></html>");
    parent.d2.document.close();
    
    parent.d3.document.open(); // write cyan
    parent.d3.document.write("<html><body bgcolor="#00"+g+b+"" "+text+"> \n Color=#00"+g+b+" \n </body></html>");
    parent.d3.document.close();
  &#125;
  
&#125;
    </script>
erroring version:

Code: Select all

<script language="javascript">
function findcolor()&#123; // find the colors
  
  /* find out what was entered */
  var hdp=(parent.cntrl.document.colortable.hdp.value); // which format
  var red=(parent.cntrl.document.colortable.red.value *1); // numerical red
  var gre=(parent.cntrl.document.colortable.green.value *1); // numerical green
  var blu=(parent.cntrl.document.colortable.blue.value *1); // numerical blue
  var hred=parent.cntrl.document.colortable.red.value; // hex red
  var hgre=parent.cntrl.document.colortable.green.value; // hex green
  var hblu=parent.cntrl.document.colortable.blue.value; // hex blue
  var hexpat=/^&#1111;0-9A-Fa-f]+$/; // any valid hex character one or more times
  var pat=/^&#1111;C-Fc-f]&#1111;0-9A-Fa-f]$/; // anything lighter than bf
  var pgstrt="<html><head><style type="text/css">\nbody &#123; background-color:#"; // start the page (static)
  var text=";\ncolor:#ffffff;\n&#125;\n"; // text color (slightly dynamic)
  var clshd="</style></head><body>Color=#"; // next (static) part of the page
  var endpg="</body></html>"; // end the page (static)
  
  function writeframe(r, g, b, text)&#123; // write to the frames;
    
    parent.b1.document.open(); // write red
    parent.b1.document.write(pgstrt+r+"0000"+text+clshd+r+"0000"+endpg);
    parent.b1.document.close();
    
    parent.b2.document.open(); // write yellow
    parent.b2.document.write(pgstrt+r+g+"00"+text+clshd+r+g+"00"+endpg);
    parent.b2.document.close();
    
    parent.b3.document.open(); // write green
    parent.b3.document.write(pgstrt+"00"+g"00"+text+clshd+"00"+g+"00"+endpg);
    parent.b3.document.close();
    
    parent.c.document.open(); // write full color
    parent.c.document.write(pgstrt+r+g+b+text+clshd+r+g+b+endpg);
    parent.c.document.close();
      
    parent.d1.document.open(); // write magenta
    parent.d1.document.write(pgstrt+r+"00"+b+text+clshd+r+"00"+b+endpg);
    parent.d1.document.close();
    
    parent.d2.document.open(); // write blue
    parent.d2.document.write(pgstrt+"0000"+b+text+clshd+"0000"+b+endpg);
    parent.d2.document.close();
    
    parent.d3.document.open(); // write cyan
    parent.d3.document.write(pgstrt+"00"+g+b+text+clshd+"00"+g+b+endpg);
    parent.d3.document.close();
  &#125;
  
&#125;
    </script>

Posted: Sun Oct 12, 2003 2:29 am
by volka
parent.b3.document.write(pgstrt+"00"+g"00"+text+clshd+"00"+g+"00"+endpg);
missing a + there between g and "00"

Posted: Sun Oct 12, 2003 11:44 am
by m3rajk
THANK YOU

i got too close to the code, after looking =for the error for a day i came here, after not getitng help for a week i killed the thread and remade it. i just kept adding the + in my mind when reading it, because i never saw it until you pointed it out. this is why i love to work in groups. most of my issues with coding are a result of that type of issue,m where i get too close and fix it in my mind so i can't find the error that everyone can see.

Posted: Sun Oct 12, 2003 9:04 pm
by volka
actually DevStudio saw it.
The inernet explorer must be good for something... ;-)

Posted: Mon Oct 13, 2003 9:01 am
by m3rajk
heh,, when i remade this i took out something else on css and tables figuring ppl were getting confused. one thing i liked about netscape i don't see in 7 or mozilla or ie is that typing "javascript" into the location bar and hitting go would give you the error if there's an error. hmm.. i should try that in mozilla next time...

Posted: Mon Oct 13, 2003 9:55 am
by McGruff
m3rajk wrote:one thing i liked about netscape i don't see in 7 or mozilla or ie is that typing "javascript" into the location bar and hitting go would give you the error if there's an error. hmm.. i should try that in mozilla next time...
I haven't used this http://www.hacksrus.com/~ginda/venkman/ myself since I'm no fan of js but it might be useful.

Lots of great developer tools available for Firebird.