Two Plus Two Newer Archives

Two Plus Two Newer Archives (http://archives1.twoplustwo.com/index.php)
-   Other Other Topics (http://archives1.twoplustwo.com/forumdisplay.php?f=36)
-   -   Quick javascript help (http://archives1.twoplustwo.com/showthread.php?t=251972)

traz 11-03-2006 06:24 PM

Quick javascript help
 
I'm a noob. All my coding works for FF, but not for IE. I was wondering if anyone was willing to check my code and help me get it working for IE as well. I can paste here or through pm or aim or whatever.

Any help would be appreciated :P

IggyWH 11-03-2006 06:28 PM

Re: Quick javascript help
 
It's been a while, but go ahead and post it. If I can't figure it out, I'm sure someone else can.

lippy 11-03-2006 06:29 PM

Re: Quick javascript help
 
There is a computer tech help forum, you may get a better response there.

Posting it here can't help. I used to be okay at Jscript editing and understand it.

traz 11-03-2006 06:32 PM

Re: Quick javascript help
 
The comp tech forum is usually dead from my experiences. I'll post the coding here. If I get help, then great. If a mod wants to move this, then thats ok too.

<font class="small">Code:</font><hr /><pre> &lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;

&lt;head&gt;
&lt;title&gt;A Simple Color Picker&lt;/title&gt;
&lt;script type="text/javascript"&gt;
/*&lt;![CDATA[*/

function Color() {
var red, green, blue;
var red1, green1, blue1;
var msg = "";

with (document.getElementById("ColorPicker"))
{

red = bgRed.value;
green = bgGreen.value;
blue = bgBlue.value;
red1 = txtRed.value;
green1 = txtGreen.value;
blue1 = txtBlue.value;

var pound = "#";
var color = red + green + blue;
var textcolor = red1 + green1 + blue1;
document.bgColor = ( pound + color);
document.fgColor = ( pound + textcolor);

}
}
function CheckData(){
var isValid = true;
var msg = "";

with (document.getElementById("ColorPicker"))
{

/* function Color */
Color();

/* bgRed must be hexadecimal*/
if (bgRed.value=="") {
isValid = false;
msg += "\n You must enter a value for Red-Background.";
}
else {
var re = /[0-9,A-F]{2}/;
var found = bgRed.value.match(re);
if ( !found ) {
isValid = false;
msg += "\n You must enter 2 hexadecimal characters for the Red-Background field";
}
}

/* bgGreen must be hexadecimal*/
if (bgGreen.value=="") {
isValid = false;
msg += "\n You must enter a value for Green-Background.";
}
else {
var re = /[0-9,A-F]{2}/;
var found = bgGreen.value.match(re);
if ( !found ) {
isValid = false;
msg += "\n You must enter 2 hexadecimal characters for the Green-Background field";
}
}

/* bgBlue must be hexadecimal*/
if (bgBlue.value=="") {
isValid = false;
msg += "\n You must enter a value for Blue-Background.";
}
else {
var re = /[0-9,A-F]{2}/;
var found = bgBlue.value.match(re);
if ( !found ) {
isValid = false;
msg += "\n You must enter 2 hexadecimal characters for the Blue-Background field";
}
}

/* txtRed must be hexadecimal*/
if (txtRed.value=="") {
isValid = false;
msg += "\n You must enter a value for Red-Text.";
}
else {
var re = /[0-9,A-F]{2}/;
var found = txtRed.value.match(re);
if ( !found ) {
isValid = false;
msg += "\n You must enter 2 hexadecimal characters for the Red-Text field";
}
}

/* txtGreen must be hexadecimal*/
if (txtGreen.value=="") {
isValid = false;
msg += "\n You must enter a value for Green-Text.";
}
else {
var re = /[0-9,A-F]{2}/;
var found = txtGreen.value.match(re);
if ( !found ) {
isValid = false;
msg += "\n You must enter 2 hexadecimal characters for the Green-Text field";
}
}

/* txtBlue must be hexadecimal*/
if (txtBlue.value=="") {
isValid = false;
msg += "\n You must enter a value for Blue-Text.";
}
else {
var re = /[0-9,A-F]{2}/;
var found = txtBlue.value.match(re);
if ( !found ) {
isValid = false;
msg += "\n You must enter 2 hexadecimal characters for the Blue-Text field";
}
}

if (msg != "") {
alert(msg);
}

return isValid;
}
}

/*]]&gt;*/
&lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;

&lt;h1 style="text-align:center"&gt;A Simple Color Picker&lt;/h1&gt;
&lt;form id="ColorPicker" method="post" action=""&gt;
&lt;table width="70%" border="1" cellpadding="5" style="align:right"&gt;
&lt;tr&gt;
&lt;td valign="top" align="left" style="width:42%"&gt;
&lt;p style="text-align:left"&gt;
Background (enter values from '00' to 'FF')
RED:&lt;input name="bgRed" type="text" size="2" maxlength="2" value="FF" /&gt;
GREEN:&lt;input name="bgGreen" type="text" size="2" maxlength="2" value="FF" /&gt;
BLUE:&lt;input name="bgBlue" type="text" size="2" maxlength="2" value="FF" /&gt;
&lt;/p&gt;
&lt;p style="text-align:left"&gt;
Text (enter values from '00' to ''FF')&lt;br/&gt;
RED:&lt;input name="txtRed" type="text" size="2" maxlength="2" value="00" /&gt;
GREEN:&lt;input name="txtGreen" type="text" size="2" maxlength="2" value="00" /&gt;
BLUE:&lt;input name="txtBlue" type="text" size="2" maxlength="2" value="00" /&gt;
&lt;/p&gt;
&lt;p style="text-align:center"&gt;
&lt;input type = "button" value = "Apply" onclick="CheckData()"/&gt;&amp;nbsp;&amp;nbsp;
&lt;input type = "reset" value = "Reload" onclick = "location.reload(true)"/&gt;
&lt;/p&gt;
&lt;/td&gt;
&lt;td valign="top" align="left"&gt;
&lt;h3&gt;Hamlet:&lt;/h3&gt;
&lt;p&gt;Speak the speech, I pray you, as I pronounced it to you...TEST&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/form&gt;

&lt;/body&gt;
&lt;/html&gt; </pre><hr />

IggyWH 11-03-2006 06:38 PM

Re: Quick javascript help
 
Do you have activex access restricted in your IE? It worked fine for me once I allowed it.

lippy 11-03-2006 06:39 PM

Re: Quick javascript help
 
Work on both FF and IE on my computer. Check your security settings in IE.

traz 11-03-2006 06:41 PM

Re: Quick javascript help
 
ok, so I'm REALLY stupid.

yea my fault, go ahead and lock the thread. Thanks whoever replied and read the thread.

BrunoThePug 11-04-2006 12:38 AM

Re: Quick javascript help
 
If you're testing javascript in FireFox there is a great FF addon called FireBug that has a great javascript debugger/console.


All times are GMT -4. The time now is 02:26 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.