Jump to content

Azurues

Members
  • Posts

    11
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Azurues's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. <div id="tut" style="background-image: url(images/chars/guide.png);"><div id="cwind"> <div id="tname">Guardian Robot</div><div id="sep"></div> <div id="speech"> <?echo"$ttext[$ptut]";?></div></div><div id="ws"></div><form action="main.php" method="POST"> <button style="font-family: normal; font-size: 14px;" name="choice" value="1" class="<?echo"$cl1[$ptut]";?>"><?echo"$choice1[$ptut]";?></button><div id="ws"></div> <button style="font-family: normal; font-size: 14px;" name="choice" value="2" class="<?echo"$cl2[$ptut]";?>"><?echo"$choice2[$ptut]";?></button><div id="ws"></div> <button style="font-family: normal; font-size: 14px;" name="choice" value="3" class="<?echo"$cl3[$ptut]";?>"><?echo"$choice3[$ptut]";?></button> </form></div> $ttext is a numerical array to display the text (the question). It is wrong since ptut is the number of answers taken (from a database). $cl1,cl2,cl3 again are a numerical arrays which display a button or don't, it's wrong due to ptut being counted wrongly. $choice1,2,3 are the choices displayed incorrectly. I can't think of a better code and how to fix that. The problem is that ptut should be counted in some different way and I can't think of any.
  2. How could I build an interactive text system? It should work like this: Text is displayed. 1-3 options (a situational amount of them) to answer displayed. Example: Are you male? Yes No You choose yes or no and it leads you to another questions based from your previous answer. Example: (a follow up to the 1st one) So you're male. Do you like cars then? Answers. And it goes on and on. The thing I need help with is the answers. I need to show them based by the previous answer but don't know how, any help?
  3. <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.
  4. The problem is as MrAdam said, the concat method. Again, I used it just to try if it would work, it's not the way I necessarily want to do it. The thing I want is to add a number . I have variables called slots. They go: slots1 slots2 slots3 etc... And in the if part I want to select a slots variable with the same number as slotNum is. So if slotNum is 5 I want to select slots5 variable and compare it. The thing is I do not know how to do so and I'm asking if anyone could help me with that :S
  5. Slots are defined at the second line. var slots1=<?php echo $slot1;?>; var slots2=<?php echo $slot2;?>;etc... etc... They're numeric strings picked from a sql database, though non arrays, I used concat just to see if it would work, don't really know javascript too well. The problem as mentioned is the if part. For comparison I want to use the slots variable and add the same number as I'm using for the dialog (info) selector. So if dialog's selector is info30 it should use slots30 for comparison.
  6. Changed variable names to slots and added the .length property. Dialog still doesn't open .
  7. Yes, I have slot variables up to 30 and want to check if the variable on which mouse hovered is more than 0,.
  8. Hey. This is my script: <script type="text/javascript"> var slot1=<?php echo $slot1;?>; var slot2=<?php echo $slot2;?>;etc... etc... $().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()]); [b]if ($(slot.concat(slotNum))>0)[/b]{ $('#info' + slotNum).dialog('open'); } }); $('[id^=slot]').mouseout(function() { $('[id^=info]').dialog('close'); }); }); The bolded part seems to be wrong because no dialog appears at all. Anyone can help me with that, how should I change the if part?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.