• Jetzt anmelden. Es dauert nur 2 Minuten und ist kostenlos!

Php in JS

SimoNxD

Mitglied
Hallo :eek:, hab jz seit 2 stunden ein problem und finde einfach nichts...
Also hab gelesen man kann in JS Php nutzen...

Ich hab den "canvas" script, zum Freirubbeln via JS runtergeladen.

Jetzt möchte ich allerdings verschiedene Bilder haben. Ganze hab ich versucht zu zu lösen:

$.fn.wScratchPad.defaultSettings =
{
width : 210, // set width - best to match image width
height : 100, // set height - best to match image height
image : 'images/<?php $whatbildInfo->bild ?>.png', // set image path
image2 : 'images/scratch-to-win.png', // set overlay image path - if set color is not used
color : '#333333', // set scratch color - if image2 is not set uses color
overlay : 'none', // set the type of overlay effect 'none', 'lighter' - only used with color
size : 10, // set size of scratcher
realtimePercent : false, // Update scratch percent only on the mouseup/touchend (for better performances on mobile device)
scratchDown : null, // scratchDown callback
scratchUp : null, // scratchUp callback
scratchMove : null, // scratcMove callback
cursor : null // Set path to custom cursor
};

Zu beachten ist hier:
image : 'images/<?php $whatbildInfo->bild ?>.png', // set image path
ich krieg keine Fehlermeldung oder so, aber er zeigt mir nichts an, bzw. aufeinmal ist alles weg, was das Javascript erzeugt...

Einer ne Idee woran es liegen könnte :/?

Das ganze ist hier zu finden:
https://github.com/websanova/wScratchPad/tags

Normalerweise ist die .js ausgelagert, ich hab allerdings den js code in der .index um dort auch php verwenden zu können (so hab ichs aufjedenfall im internet gelsen)
MfG
 
Werbung:
7cpPa.jpg


Als vergleich:

7cq20.jpg


Hab nochmal genauer geschaut

Oben ist die Variable "image" (von jS denke ich)
Und unten wird das hintergrundimage festgelegt:

setBgImage: function()
{
if(this.settings.image)
{
this.sp.css({backgroundImage: 'url('+this.settings.image+')'});
}
},

Wenn ich das richtig verstanden habe.
Wie änder ich jetzt das untere "setBgImage:function, das ich backgroundImage = $phpvariable habe?
 
Werbung:
setBgImage: function()
{
if(this.settings.image)
{
this.sp.css({backgroundImage: 'url('+this.settings.<?php echo $variable; ?>+')'});
}
},

? So?
 
Werbung:
Zurück
Oben