Hallo,
ich habe irgendwo im Internet folgenden Code gefunden. Man soll damit in einem PopUp eine Farbe auswählen können und die wird dann automatisch in ein Eingabefeld im Mutterfenster geschrieben. Das Problem ist allerdings, dass ich nur den Code für das PopUp Fenster habe. Könnt ihr mir vielleicht bei dem JS-Code für das Mutterfenster helfen ?
Hier ist der PopUp-Code:
Code:
<html STYLE="width: 238px; height: 187px">
<head>
<title>Farbe wählen</title>
<script language="javascript">
function _CloseOnEsc() {
if (event.keyCode == 27) { window.close(); return; }
}
function Init() { // run on page load
document.body.onkeypress = _CloseOnEsc;
color = window.dialogArguments;
color = ValidateColor(color) || '000000';
View(color); // set default color
}
function View(color) { // preview color
document.all.ColorPreview.style.backgroundColor = '#' + color;
document.all.ColorHex.value = '#' + color;
}
function Set(string) { // select color
color = ValidateColor(string);
if (color == null) { alert("Invalid color code: " + string); } // invalid color
else { // valid color
View(color); // show selected color
window.returnValue = color; // set return value
window.close(); // close dialog
}
}
function ValidateColor(string) { // return valid color code
string = string || '';
string = string + "";
string = string.toUpperCase();
chars = '0123456789ABCDEF';
out = '';
for (i=0; i<string.length; i++) { // remove invalid color chars
schar = string.charAt(i);
if (chars.indexOf(schar) != -1) { out += schar; }
}
if (out.length != 6) { return null; } // check length
return out;
}
</script>
</head>
<body bgcolor="#ECF7DF" topmargin=0 leftmargin=0 onload="Init()">
<form method=get onSubmit="Set(document.all.ColorHex.value); return false;">
<table border=0 cellspacing=0 cellpadding=4 width=100%>
<tr>
<td bgcolor="#FFFFFF" valign=center><div style="background-color: #000000; padding: 1; height: 21px; width: 50px"><div id="ColorPreview" style="height: 100%; width: 100%"></div></div></td>
<td bgcolor="#D6DED1" valign=center><input type="text" name="ColorHex" value="" size=15 style="font-size: 12px"></td>
<td bgcolor="#D6DED1" width=100%></td>
</tr>
</table>
<table border=0 cellspacing=1 cellpadding=0 bgcolor=#000000 style="cursor: hand;">
<tr>
<td bgcolor=#000000 onMouseOver=View('000000') onClick=Set('000000') height=10 width=10></td>
<td bgcolor=#000000 onMouseOver=View('000000') onClick=Set('000000') height=10 width=10></td>
<td bgcolor=#000000 onMouseOver=View('000000') onClick=Set('000000') height=10 width=10></td>
<td bgcolor=#000000 onMouseOver=View('000000') onClick=Set('000000') height=10 width=10></td>
<td bgcolor=#003300 onMouseOver=View('003300') onClick=Set('003300') height=10 width=10></td>
<td bgcolor=#006600 onMouseOver=View('006600') onClick=Set('006600') height=10 width=10></td>
<td bgcolor=#009900 onMouseOver=View('009900') onClick=Set('009900') height=10 width=10></td>
<td bgcolor=#00CC00 onMouseOver=View('00CC00') onClick=Set('00CC00') height=10 width=10></td>
<td bgcolor=#00FF00 onMouseOver=View('00FF00') onClick=Set('00FF00') height=10 width=10></td>
<td bgcolor=#330000 onMouseOver=View('330000') onClick=Set('330000') height=10 width=10></td>
<td bgcolor=#333300 onMouseOver=View('333300') onClick=Set('333300') height=10 width=10></td>
<td bgcolor=#336600 onMouseOver=View('336600') onClick=Set('336600') height=10 width=10></td>
<td bgcolor=#339900 onMouseOver=View('339900') onClick=Set('339900') height=10 width=10></td>
<td bgcolor=#33CC00 onMouseOver=View('33CC00') onClick=Set('33CC00') height=10 width=10></td>
<td bgcolor=#33FF00 onMouseOver=View('33FF00') onClick=Set('33FF00') height=10 width=10></td>
<td bgcolor=#660000 onMouseOver=View('660000') onClick=Set('660000') height=10 width=10></td>
<td bgcolor=#663300 onMouseOver=View('663300') onClick=Set('663300') height=10 width=10></td>
<td bgcolor=#666600 onMouseOver=View('666600') onClick=Set('666600') height=10 width=10></td>
<td bgcolor=#669900 onMouseOver=View('669900') onClick=Set('669900') height=10 width=10></td>
<td bgcolor=#66CC00 onMouseOver=View('66CC00') onClick=Set('66CC00') height=10 width=10></td>
<td bgcolor=#66FF00 onMouseOver=View('66FF00') onClick=Set('66FF00') height=10 width=10></td>
</tr>
</table>
</form>
</body></html>
Es wäre echt nett, wenn ihr mir da helfen könntet.
Danke
Sven