<script type="text/javascript">
var slots1=<?php echo $slot1;?>; var slots2=<?php echo $slot2;?>;var slots3=<?php echo $slot3;?>; var slots4=<?php echo $slot4;?>; var slots5=<?php echo $slot5;?>; var slots6=<?php echo $slot6;?>; var slots7=<?php echo $slot7;?>; var slots8=<?php echo $slot8;?>; var slots9=<?php echo $slot9;?>; var slots10=<?php echo $slot10;?>;
var slots11=<?php echo $slot11;?>; var slots12=<?php echo $slot12;?>; var slots13=<?php echo $slot13;?>; var slots14=<?php echo $slot14;?>; var slots15=<?php echo $slot15;?>; var slots16=<?php echo $slot16;?>; var slots17=<?php echo $slot17;?>; var slots18=<?php echo $slot18;?>; var slots19=<?php echo $slot19;?>; var slots20=<?php echo $slot20;?>;
var slots21=<?php echo $slot21;?>; var slots22=<?php echo $slot22;?>; var slots23=<?php echo $slot23;?>; var slots24=<?php echo $slot24;?>; var slots25=<?php echo $slot25;?>; var slots26=<?php echo $slot26;?>; var slots27=<?php echo $slot27;?>; var slots28=<?php echo $slot28;?>; var slots29=<?php echo $slot29;?>; var slots30=<?php echo $slot30;?>;
$(document).ready( function () {
$(function() {
$('[id^=info]').dialog({
dialogClass: 'notitle',
autoOpen: false,
width: '75',
height: 'auto',
resizable: false
});
});
$('[id^=slot]').mouseover(function() {
var slotIdPrefix = 'slot';
var slotNum = $(this).attr('id').substring((slotIdPrefix.length));
var slotOffset = $('#slot' + slotNum).offset();
var slotWidth = $('#slot' + slotNum).width();
var dialogWidth = $('#info' + slotNum).dialog('option', 'width');
$('#info' + slotNum).dialog('option','position',[slotOffset.left+slotWidth+153-dialogWidth,slotOffset.top+32-$(window).scrollTop()]);
if ($('slots' + slotNum) > 0){
$('#info' + slotNum).dialog('open');
} });
$('[id^=slot]').mouseout(function() {
$('[id^=info]').dialog('close');
});
});
</script>
Almost no changes since I didn't have much time. The if part at the end is another failed try of mine to get what I want, again, I'm not experienced at js and that is the only thing where I need help, adding the a number to the end of slots prefix and using it as a variable to compare.
Output with the if part:
http://sciencewar.hostme.lt/images/inv.bmp
(mouse is over an item which should bring out the dialog)
Output without the if:
http://sciencewar.hostme.lt/images/inv2.bmp
This is how it should be but the problem is that it still brings out the dialog on slots(those squares) where there aren't any items(pictures), that is why I want to use the if part, each item has a value which is stored in each slots variable.