Javascript "clonen"
Hallo, ich habe heute etwas schwieriges & zwar möchte ich ein Javascript mehrmals auf einer Seite nutzen, leider weiß ich nicht genau, wie ich ein Javascript clonen kann. Weiß einer wie folgendes JS mehrmals auf einer Seite nutzen kann, bzw es clonen kann?
Hier klicken für weitere Informationen
Ein anderer Color-Picker, der R G P (in 3 Input-Felder) setzt (nicht HEX) & mehrmals auf einer Seite nutzbar ist, wäre natürlich auch eine Lösung.
Danke im Voraus!
MfG
Die JS-Datei
HTML-Inhalt:
|
|
Javascript-Quelltext |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 |
var Colors = new function() { this.ColorFromHSV = function(hue, sat, val) { var color = new Color(); color.SetHSV(hue,sat,val); return color; } this.ColorFromRGB = function(r, g, b) { var color = new Color(); color.SetRGB(r,g,b); return color; } this.ColorFromHex = function(hexStr) { var color = new Color(); color.SetHexString(hexStr); return color; } function Color() { //Stored as values between 0 and 1 var red = 0; var green = 0; var blue = 0; //Stored as values between 0 and 360 var hue = 0; //Strored as values between 0 and 1 var saturation = 0; var value = 0; this.SetRGB = function(r, g, b) { if (isNaN(r) || isNaN(g) || isNaN(b)) return false; r = r/255.0; red = r > 1 ? 1 : r < 0 ? 0 : r; g = g/255.0; green = g > 1 ? 1 : g < 0 ? 0 : g; b = b/255.0; blue = b > 1 ? 1 : b < 0 ? 0 : b; calculateHSV(); return true; } this.Red = function() { return Math.round(red*255); } this.Green = function() { return Math.round(green*255); } this.Blue = function() { return Math.round(blue*255); } this.SetHSV = function(h, s, v) { if (isNaN(h) || isNaN(s) || isNaN(v)) return false; hue = (h >= 360) ? 359.99 : (h < 0) ? 0 : h; saturation = (s > 1) ? 1 : (s < 0) ? 0 : s; value = (v > 1) ? 1 : (v < 0) ? 0 : v; calculateRGB(); return true; } this.Hue = function() { return hue; } this.Saturation = function() { return saturation; } this.Value = function() { return value; } this.SetHexString = function(hexString) { if(hexString == null || typeof(hexString) != "string") return false; if (hexString.substr(0, 1) == '#') hexString = hexString.substr(1); if(hexString.length != 6) return false; var r = parseInt(hexString.substr(0, 2), 16); var g = parseInt(hexString.substr(2, 2), 16); var b = parseInt(hexString.substr(4, 2), 16); return this.SetRGB(r,g,b); } this.HexString = function() { var rStr = this.Red().toString(16); if (rStr.length == 1) rStr = '0' + rStr; var gStr = this.Green().toString(16); if (gStr.length == 1) gStr = '0' + gStr; var bStr = this.Blue().toString(16); if (bStr.length == 1) bStr = '0' + bStr; return ('#' + rStr + gStr + bStr).toUpperCase(); } this.Complement = function() { var newHue = (hue>= 180) ? hue - 180 : hue + 180; var newVal = (value * (saturation - 1) + 1); var newSat = (value*saturation) / newVal; var newColor = new Color(); newColor.SetHSV(newHue, newSat, newVal); return newColor; } function calculateHSV() { var max = Math.max(Math.max(red, green), blue); var min = Math.min(Math.min(red, green), blue); value = max; saturation = 0; if(max != 0) saturation = 1 - min/max; hue = 0; if(min == max) return; var delta = (max - min); if (red == max) hue = (green - blue) / delta; else if (green == max) hue = 2 + ((blue - red) / delta); else hue = 4 + ((red - green) / delta); hue = hue * 60; if(hue <0) hue += 360; } function calculateRGB() { red = value; green = value; blue = value; if(value == 0 || saturation == 0) return; var tHue = (hue / 60); var i = Math.floor(tHue); var f = tHue - i; var p = value * (1 - saturation); var q = value * (1 - saturation * f); var t = value * (1 - saturation * (1 - f)); switch(i) { case 0: red = value; green = t; blue = p; break; case 1: red = q; green = value; blue = p; break; case 2: red = p; green = value; blue = t; break; case 3: red = p; green = q; blue = value; break; case 4: red = t; green = p; blue = value; break; default: red = value; green = p; blue = q; break; } } } } (); function Position(x, y) { this.X = x; this.Y = y; this.Add = function(val) { var newPos = new Position(this.X, this.Y); if(val != null) { if(!isNaN(val.X)) newPos.X += val.X; if(!isNaN(val.Y)) newPos.Y += val.Y } return newPos; } this.Subtract = function(val) { var newPos = new Position(this.X, this.Y); if(val != null) { if(!isNaN(val.X)) newPos.X -= val.X; if(!isNaN(val.Y)) newPos.Y -= val.Y } return newPos; } this.Min = function(val) { var newPos = new Position(this.X, this.Y) if(val == null) return newPos; if(!isNaN(val.X) && this.X > val.X) newPos.X = val.X; if(!isNaN(val.Y) && this.Y > val.Y) newPos.Y = val.Y; return newPos; } this.Max = function(val) { var newPos = new Position(this.X, this.Y) if(val == null) return newPos; if(!isNaN(val.X) && this.X < val.X) newPos.X = val.X; if(!isNaN(val.Y) && this.Y < val.Y) newPos.Y = val.Y; return newPos; } this.Bound = function(lower, upper) { var newPos = this.Max(lower); return newPos.Min(upper); } this.Check = function() { var newPos = new Position(this.X, this.Y); if(isNaN(newPos.X)) newPos.X = 0; if(isNaN(newPos.Y)) newPos.Y = 0; return newPos; } this.Apply = function(element) { if(typeof(element) == "string") element = document.getElementById(element); if(element == null) return; if(!isNaN(this.X)) element.style.left = this.X + 'px'; if(!isNaN(this.Y)) element.style.top = this.Y + 'px'; } } var pointerOffset = new Position(0, navigator.userAgent.indexOf("Firefox") >= 0 ? 1 : 0); var circleOffset = new Position(5, 5); var arrowsOffset = new Position(0, 4); var arrowsLowBounds = new Position(0, -4); var arrowsUpBounds = new Position(0, 251); var circleLowBounds = new Position(-5, -5); var circleUpBounds = new Position(250, 250); function correctOffset(pos, offset, neg) { if(neg) return pos.Subtract(offset); return pos.Add(offset); } function hookEvent(element, eventName, callback) { if(typeof(element) == "string") element = document.getElementById(element); if(element == null) return; if(element.addEventListener) { element.addEventListener(eventName, callback, false); } else if(element.attachEvent) element.attachEvent("on" + eventName, callback); } function unhookEvent(element, eventName, callback) { if(typeof(element) == "string") element = document.getElementById(element); if(element == null) return; if(element.removeEventListener) element.removeEventListener(eventName, callback, false); else if(element.detachEvent) element.detachEvent("on" + eventName, callback); } function cancelEvent(e) { e = e ? e : window.event; if(e.stopPropagation) e.stopPropagation(); if(e.preventDefault) e.preventDefault(); e.cancelBubble = true; e.cancel = true; e.returnValue = false; return false; } function getMousePos(eventObj) { eventObj = eventObj ? eventObj : window.event; var pos; if(isNaN(eventObj.layerX)) pos = new Position(eventObj.offsetX, eventObj.offsetY); else pos = new Position(eventObj.layerX, eventObj.layerY); return correctOffset(pos, pointerOffset, true); } function getEventTarget(e) { e = e ? e : window.event; return e.target ? e.target : e.srcElement; } function absoluteCursorPostion(eventObj) { eventObj = eventObj ? eventObj : window.event; if(isNaN(window.scrollX)) return new Position(eventObj.clientX + document.documentElement.scrollLeft + document.body.scrollLeft, eventObj.clientY + document.documentElement.scrollTop + document.body.scrollTop); else return new Position(eventObj.clientX + window.scrollX, eventObj.clientY + window.scrollY); } function dragObject(element, attachElement, lowerBound, upperBound, startCallback, moveCallback, endCallback, attachLater) { if(typeof(element) == "string") element = document.getElementById(element); if(element == null) return; if(lowerBound != null && upperBound != null) { var temp = lowerBound.Min(upperBound); upperBound = lowerBound.Max(upperBound); lowerBound = temp; } var cursorStartPos = null; var elementStartPos = null; var dragging = false; var listening = false; var disposed = false; function dragStart(eventObj) { if(dragging || !listening || disposed) return; dragging = true; if(startCallback != null) startCallback(eventObj, element); cursorStartPos = absoluteCursorPostion(eventObj); elementStartPos = new Position(parseInt(element.style.left), parseInt(element.style.top)); elementStartPos = elementStartPos.Check(); hookEvent(document, "mousemove", dragGo); hookEvent(document, "mouseup", dragStopHook); return cancelEvent(eventObj); } function dragGo(eventObj) { if(!dragging || disposed) return; var newPos = absoluteCursorPostion(eventObj); newPos = newPos.Add(elementStartPos).Subtract(cursorStartPos); newPos = newPos.Bound(lowerBound, upperBound) newPos.Apply(element); if(moveCallback != null) moveCallback(newPos, element); return cancelEvent(eventObj); } function dragStopHook(eventObj) { dragStop(); return cancelEvent(eventObj); } function dragStop() { if(!dragging || disposed) return; unhookEvent(document, "mousemove", dragGo); unhookEvent(document, "mouseup", dragStopHook); cursorStartPos = null; elementStartPos = null; if(endCallback != null) endCallback(element); dragging = false; } this.Dispose = function() { if(disposed) return; this.StopListening(true); element = null; attachElement = null lowerBound = null; upperBound = null; startCallback = null; moveCallback = null endCallback = null; disposed = true; } this.StartListening = function() { if(listening || disposed) return; listening = true; hookEvent(attachElement, "mousedown", dragStart); } this.StopListening = function(stopCurrentDragging) { if(!listening || disposed) return; unhookEvent(attachElement, "mousedown", dragStart); listening = false; if(stopCurrentDragging && dragging) dragStop(); } this.IsDragging = function(){ return dragging; } this.IsListening = function() { return listening; } this.IsDisposed = function() { return disposed; } if(typeof(attachElement) == "string") attachElement = document.getElementById(attachElement); if(attachElement == null) attachElement = element; if(!attachLater) this.StartListening(); } function arrowsDown(e, arrows) { var pos = getMousePos(e); if(getEventTarget(e) == arrows) pos.Y += parseInt(arrows.style.top); pos = correctOffset(pos, arrowsOffset, true); pos = pos.Bound(arrowsLowBounds, arrowsUpBounds); pos.Apply(arrows); arrowsMoved(pos); } function circleDown(e, circle) { var pos = getMousePos(e); if(getEventTarget(e) == circle) { pos.X += parseInt(circle.style.left); pos.Y += parseInt(circle.style.top); } pos = correctOffset(pos, circleOffset, true); pos = pos.Bound(circleLowBounds, circleUpBounds); pos.Apply(circle); circleMoved(pos); } function arrowsMoved(pos, element) { pos = correctOffset(pos, arrowsOffset, false); currentColor.SetHSV((256 - pos.Y)*359.99/255, currentColor.Saturation(), currentColor.Value()); colorChanged("arrows"); } function circleMoved(pos, element) { pos = correctOffset(pos, circleOffset, false); currentColor.SetHSV(currentColor.Hue(), 1-pos.Y/255.0, pos.X/255.0); colorChanged("circle"); } function colorChanged(source) { document.getElementById("hexBox").value = currentColor.HexString(); document.getElementById("redBox").value = currentColor.Red(); document.getElementById("greenBox").value = currentColor.Green(); document.getElementById("blueBox").value = currentColor.Blue(); document.getElementById("hueBox").value = Math.round(currentColor.Hue()); var str = (currentColor.Saturation()*100).toString(); if(str.length > 4) str = str.substr(0,4); document.getElementById("saturationBox").value = str; str = (currentColor.Value()*100).toString(); if(str.length > 4) str = str.substr(0,4); document.getElementById("valueBox").value = str; if(source == "arrows" || source == "box") document.getElementById("gradientBox").style.backgroundColor = Colors.ColorFromHSV(currentColor.Hue(), 1, 1).HexString(); if(source == "box") { var el = document.getElementById("arrows"); el.style.top = (256 - currentColor.Hue()*255/359.99 - arrowsOffset.Y) + 'px'; var pos = new Position(currentColor.Value()*255, (1-currentColor.Saturation())*255); pos = correctOffset(pos, circleOffset, true); pos.Apply("circle"); endMovement(); } document.getElementById("quickColor").style.backgroundColor = currentColor.HexString(); } function endMovement() { document.getElementById("staticColor").style.backgroundColor = currentColor.HexString(); } function hexBoxChanged(e) { currentColor.SetHexString(document.getElementById("hexBox").value); colorChanged("box"); } function redBoxChanged(e) { currentColor.SetRGB(parseInt(document.getElementById("redBox").value), currentColor.Green(), currentColor.Blue()); colorChanged("box"); } function greenBoxChanged(e) { currentColor.SetRGB(currentColor.Red(), parseInt(document.getElementById("greenBox").value), currentColor.Blue()); colorChanged("box"); } function blueBoxChanged(e) { currentColor.SetRGB(currentColor.Red(), currentColor.Green(), parseInt(document.getElementById("blueBox").value)); colorChanged("box"); } function hueBoxChanged(e) { currentColor.SetHSV(parseFloat(document.getElementById("hueBox").value), currentColor.Saturation(), currentColor.Value()); colorChanged("box"); } function saturationBoxChanged(e) { currentColor.SetHSV(currentColor.Hue(), parseFloat(document.getElementById("saturationBox").value)/100.0, currentColor.Value()); colorChanged("box"); } function valueBoxChanged(e) { currentColor.SetHSV(currentColor.Hue(), currentColor.Saturation(), parseFloat(document.getElementById("valueBox").value)/100.0); colorChanged("box"); } function fixPNG(myImage) { if(!document.body.filters) return; var arVersion = navigator.appVersion.split("MSIE"); var version = parseFloat(arVersion[1]); if(version < 5.5 || version >= 7) return; var imgID = (myImage.id) ? "id='" + myImage.id + "' " : "" var imgStyle = "display:inline-block;" + myImage.style.cssText var strNewHTML = "<span " + imgID + " style=\"" + "width:" + myImage.width + "px; height:" + myImage.height + "px;" + imgStyle + ";" + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" + "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>" myImage.outerHTML = strNewHTML } function fixGradientImg() { fixPNG(document.getElementById("gradientImg")); } |
HTML-Inhalt:
|
|
HTML |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
R<input type="text" size="3" name="rgb2_r" style="text-align: center" maxlength="3" id="redBox2" onchange="redBoxChanged();" /> G<input type="text" size="3" name="rgb2_g" style="text-align: center" maxlength="3" id="greenBox2" onchange="greenBoxChanged();" /> B<input type="text" size="3" name="rgb2_b" style="text-align: center" maxlength="3" id="blueBox2" onchange="blueBoxChanged();" /> <img src="plus.png" id="imgcp2" alt="" border="0" onclick="colpic('cp2');" style="cursor: pointer;" /> <div style="position:relative;height:290px;width:530px;border:1px solid black;display:none;" id="cp2"> <div id="gradientBox2" style="cursor:crosshair;position:absolute;top:15px;left:15px;width:256px;height:256px;"> <img id="gradientImg2" style="display:block;width:256px;height:256px;" src="color_picker_gradient.png" alt="" /> <img id="circle2" style="position:absolute;height:11px;width:11px;" src="color_picker_circle.gif" alt="" /> </div> <div id="hueBarDiv2" style="position:absolute;left:310px;width:35px;height:256px;top:15px;"> <img style="position:absolute;height:256px;width:19px;left:8px;" src="color_picker_bar.png" alt="" /> <img id="arrows2" style="position:absolute;height:9px;width:35px;left:0px;" src="color_picker_arrows.gif" alt="" /> <br /> </div> <div style="position:absolute;left:370px;width:145px;height:256px;top:15px;"> <div style="position:absolute;border: 1px solid black;height:50px;width:145px;top:0px;left:0px;"> <div id="quickColor2" style="position:absolute;height:50px;width:73px;top:0px;left:0px;"></div> <div id="staticColor2" style="position:absolute;height:50px;width:72px;top:0px;left:73px;"></div> </div> <br /> <table width="100%" style="position:absolute;top:55px;"> <tr> <td>Hex: </td> <td> <input style="margin:0.3em;" size="7" type="text" id="hexBox2" onchange="hexBoxChanged();" /> </td> </tr> <tr> <td>Hue: </td> <td> <input style="margin:0.3em;" size="7" type="text" id="hueBox2" onchange="hueBoxChanged();" /> </td> </tr> <tr> <td>Saturation: </td> <td> <input style="margin:0.3em;" size="7" type="text" id="saturationBox2" onchange="saturationBoxChanged();" /> </td> </tr> <tr> <td>Value: </td> <td> <input style="margin:0.3em;" size="7" type="text" id="valueBox2" onchange="valueBoxChanged();" /> </td> </tr> </table> </div> </div> <script type="text/javascript"> fixGradientImg(); var currentColor = Colors.ColorFromRGB(255,255,255); new dragObject("arrows2", "hueBarDiv2", arrowsLowBounds, arrowsUpBounds, arrowsDown, arrowsMoved, endMovement); new dragObject("circle2", "gradientBox2", circleLowBounds, circleUpBounds, circleDown, circleMoved, endMovement); colorChanged('box'); </script>'; |
Ein anderer Color-Picker, der R G P (in 3 Input-Felder) setzt (nicht HEX) & mehrmals auf einer Seite nutzbar ist, wäre natürlich auch eine Lösung.
Danke im Voraus!
MfG
Es geht nicht darum zu haben was man will, sondern zu schätzen was man hat!
Blutrausch HP
Mauern sind auch nur Steine & Wassertropen können auch mal Wassermengen werden!
Blutrausch HP
Mauern sind auch nur Steine & Wassertropen können auch mal Wassermengen werden!
Ja, es gibt keine site.htm, da es hier kein PHPKIT Bereich ist & ich möchte das Script mehrmals auf einer geöffneten Seite nutzen.
MfG
MfG
Es geht nicht darum zu haben was man will, sondern zu schätzen was man hat!
Blutrausch HP
Mauern sind auch nur Steine & Wassertropen können auch mal Wassermengen werden!
Blutrausch HP
Mauern sind auch nur Steine & Wassertropen können auch mal Wassermengen werden!
Da es eine Funktion ist, brauchst du diese im Grunde nur mehrmals aufrufen, an den stellen, an der du sie eben aufrufen musst. Den Code setzt du demnach nur einmal ein. Der Aufruf ist entscheidend. Schau nochmal da nach, wo du den Code her hast. Da steht ja irgendwo, wie du den Picker aufrufst. Diesen Aufruf musst du dann ja nur an mehreren Stellen Platzieren. Hab mir deinen HTML Code jetzt nicht weiter angesehen, da die Informationen für mich derzeit zu viel sind
Ne geht leider nicht, da die Input Felder einer festen ID zugewiesen sind
Es geht nicht darum zu haben was man will, sondern zu schätzen was man hat!
Blutrausch HP
Mauern sind auch nur Steine & Wassertropen können auch mal Wassermengen werden!
Blutrausch HP
Mauern sind auch nur Steine & Wassertropen können auch mal Wassermengen werden!
Moin Moin 
Habe mir den Quelltext jetzt auch nicht angesehen......
Wie aber MaXus bereits geschrieben hat, sind Funktionen schließlich dafür da, um sie mehrmals benutzen zu können bzw. um immer wiederkehrende Aufgaben zentral abarbeiten zu können.
Für Dich heißt dies nun "ganz einfach":
Die Funktion, die z.B. den Eintrag in das entsprechende Inputfeld vornehmen soll, muss einen weiteren Parameter aufnehmen können - nämlich die ID des Inputfeldes.
Der Funktionsaufruf muss dann natürlich auch um die entsprechende ID erweitert werden.
Ein verdammt simples Beispiel für die Nutzung einer Funktion mit verschiedenen Werten und verschiedenen Textfeldern:
Dementsprechend musst Du eben in Deinem Script die Funktion suchen, die den Eintrag nach einem Klick auf die Farbe vornimmt.......
Netten Gruß
Andy --- Proggi

Habe mir den Quelltext jetzt auch nicht angesehen......
Wie aber MaXus bereits geschrieben hat, sind Funktionen schließlich dafür da, um sie mehrmals benutzen zu können bzw. um immer wiederkehrende Aufgaben zentral abarbeiten zu können.
Für Dich heißt dies nun "ganz einfach":
Die Funktion, die z.B. den Eintrag in das entsprechende Inputfeld vornehmen soll, muss einen weiteren Parameter aufnehmen können - nämlich die ID des Inputfeldes.
Der Funktionsaufruf muss dann natürlich auch um die entsprechende ID erweitert werden.
Ein verdammt simples Beispiel für die Nutzung einer Funktion mit verschiedenen Werten und verschiedenen Textfeldern:
|
|
HTML |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
<script type="text/javascript"> this.setzeZahl = function(zahl, textfeld) { document.getElementById(textfeld).value = zahl; } </script> <form> <input type="button" name="zahl1set" value="Zahl 5 in das Textfeld" onclick="setzeZahl(5,'zahl1');" /> <input type="text" name="zahl1" id="zahl1" value="" size="5" /> <input type="button" name="zahl1set" value="Zahl 3 in das Textfeld" onclick="setzeZahl(3,'zahl1');" /> <hr /> <input type="button" name="zahl2set" value="Zahl 10 in das Textfeld" onclick="setzeZahl(10,'zahl2');" /> <input type="text" name="zahl2" id="zahl2" value="" size="5" /> <input type="button" name="zahl2set" value="Zahl 8 in das Textfeld" onclick="setzeZahl(8,'zahl2');" /> </form> |
Dementsprechend musst Du eben in Deinem Script die Funktion suchen, die den Eintrag nach einem Klick auf die Farbe vornimmt.......

Netten Gruß
Andy --- Proggi
so wie ich das sehe übergibst du schon etwas?!
bzw, kannst du anhand von deinem code gut handeln...
du übergibst eine 2..
was passiert denn wenn du genau diese ziffer variable machst?!
anstelle von colpic('cp2') kannste ja das cp weglassen und colpic('2') machen.. dann übergibst du jene zahl, welche im formular auch vorhanden ist und kannst dies auswerten..
den rest können dir die anderen erklären XD
bzw, kannst du anhand von deinem code gut handeln...
Zitat
Hier die einzelnen Inputfelder:
id="redBox2"
id="greenBox2"
id="blueBox2"
das bild enthält folgenden aufruf:
onclick="colpic('cp2');"
du übergibst eine 2..
was passiert denn wenn du genau diese ziffer variable machst?!
anstelle von colpic('cp2') kannste ja das cp weglassen und colpic('2') machen.. dann übergibst du jene zahl, welche im formular auch vorhanden ist und kannst dies auswerten..
den rest können dir die anderen erklären XD
|
Achtung: Dirk Kántor ist unterwegs! Er verteilt gerne Verwarnungen ohne vorher darüber diskutiert zu haben. php-gfx.net Archiv | Addon Room | Scripte | v/Root Server |
Das colpic ist nur eine Klappfunktion & die Vergabe von id="redBox2" usw, habe ich erfolglos als erstes ausprobiert.
Es geht nicht darum zu haben was man will, sondern zu schätzen was man hat!
Blutrausch HP
Mauern sind auch nur Steine & Wassertropen können auch mal Wassermengen werden!
Blutrausch HP
Mauern sind auch nur Steine & Wassertropen können auch mal Wassermengen werden!
Ähnliche Themen
-
Web | Programmierung »-
Klapptext Java Frage^^
(30. März 2010, 04:52)
-
alte Versionen [1.6.03|1.6.1|1.6.4] »-
pkSpellCheck
(19. Februar 2009, 10:44)
-
Web | Allgemein »-
Bannerwechsel auf Knopfdruck
(14. Juli 2008, 22:07)
-
alte Versionen [1.6.03|1.6.1|1.6.4] »-
IM-Center- PW abfrage und Benutzer nicht gefunden
(12. März 2008, 19:36)



