Jump to content

JimTEFL

Members
  • Posts

    4
  • Joined

  • Last visited

Everything posted by JimTEFL

  1. Thanks to W3Schools I have been able to create a small board game called "Papillon" very loosely based on the film of the same name. The purpose of the game is for green to reach the top of the board and for the reds to prevent this. Green should try to force the reds to bend or break their line and the reds should try to keep a straight horizontal line across the board. It needs four refinements: 1) a counter modulus to regulate the order of the moves between green and red:- green/red/green...... I have tried to insert this into the drag/drop functions but with no success. 2) a random device to position the green on any one of squares 29, 30, 31 or 32 at the start of the game. I tried to juggle the div id = dr5 into one of these but again without success. 3) control of the extent of moves by green (green can move x and y + or - one square width) and red (red can only move x + or - one square width and y + one square width) I tried to set up variables to identify the start location of any piece to compare it with the target location. No matter how I tried I simply could not identify any start location of any piece. The target location is easy to identify. 4) Preventing a move onto a square already occupied. I confess not having tried very hard with this point. I have constructed simple card and board games in VB6. Perhaps it is Vb6 thinking that prevents me from solving these JavaScript problems. I look forward to any effective help, please. butterfly.html
  2. I can drag and drop draggable elements onto targets but need to compare the source div with the target div so that I can control where I drop the dragged element. The drag/drop functions identify the target divs but not the source divs. I want to be able to compare as follows: There are 32 target divs. Let the draggable element be on source div6. It can be moved onto div2, div3, div10 or div11, so:- if(div6 - targetdiv == -2 or -3 or 4 or 5) {return;} [to allow a valid drop] else {return:false;} [to prevent invalid drop] How can I identify the source div, please, to control my drag drops?
  3. Many many thanks to both davej and Hadien. davej I shall use your second piece of code. Brilliant for my purposes. Hadien Same to you!
  4. <html><head></head><body><h2>English Level Test</h2>There should be a picture of a man here sitting at his desk.<br> He has dark hair and a beard and is holding a piece of paper.<br> Please use your imagination until I insert an image! <br> <p>1. This man has dark ............<script>function testAns1(myAns1) { if(myAns1 == 1) {document.write(1);} else {document.write(0); } }</script> <input type="radio" name="r1" value="1" onclick="testAns1(this.value);"/> hair <input type="radio" name="r1" value="2" onclick="testAns1(this.value);"/> heads <input type="radio" name="r1" value="3" onclick="testAns1(this.value);"/> hairs <input type="radio" name="r1" value="4" onclick="testAns1(this.value);"/> head</p> <p>2. and has a ..........<script>function testAns2(myAns2) { if(myAns2 == 2) {document.write(1);} else {document.write(0); } }</script> <input type="radio" name="r2" value="1" onclick="testAns2(this.value);"/> bread <input type="radio" name="r2" value="2" onclick="testAns2(this.value);"/> beard <input type="radio" name="r2" value="3" onclick="testAns2(this.value);"/> barber <input type="radio" name="r2" value="4" onclick="testAns2(this.value);"/> facehair</p> <p>3. He is.......... a jacket <script>function testAns3(myAns3) { if(myAns3 == 3) {document.write(1);} else {document.write(0); } }</script> <input type="radio" name="r3" value="1" onclick="testAns3(this.value);"/> carrying <input type="radio" name="r3" value="2" onclick="testAns3(this.value);"/> having <input type="radio" name="r3" value="3" onclick="testAns3(this.value);"/> wearing <input type="radio" name="r3" value="4" onclick="testAns3(this.value);"/> putting</p> <p>4. and he is ..........a piece of paper<script>function testAns4(myAns4) { if(myAns4 == 4) {document.write(1);} else {document.write(0); } }</script> <input type="radio" name="r4" value="1" onclick="testAns4(this.value);"/> wearing <input type="radio" name="r4" value="2" onclick="testAns4(this.value);"/> having <input type="radio" name="r4" value="3" onclick="testAns4(this.value);"/> getting <input type="radio" name="r4" value="4" onclick="testAns4(this.value);"/> holding</p> <p>5. He is sitting at his...........<script>function testAns5(myAns5) { if(myAns5 == 1) {document.write(1);} else {document.write(0); } }</script> <input type="radio" name="r5" value="1" onclick="testAns5(this.value);"/> desk <input type="radio" name="r5" value="2" onclick="testAns5(this.value);"/> chair <input type="radio" name="r5" value="3" onclick="testAns5(this.value);"/> office <input type="radio" name="r5" value="4" onclick="testAns5(this.value);"/> room</p></body></html> I am trying to create applications such as the above multi-choice test for my English material which I give to my client students of English. I want to use HTML5 and JavaScript without the use of the "Submit" method. If the above text is copied and saved as fs5.html you can see that it works up to a point. I have tried to store the result of each question in a variables (score1, score2...scoren) but cannot prevent the disappearance of the test before it is finished, either with "document.write" used above or with "alert". Can somebody please tell me how I can store each result so that I can process it by addition to produce a total of all the correct answers and then still in the same application use a message box to tell my student the score? It is my intention to send these applications as text files in Notepad and for them to copy and save them on their own computers. These will go mainly to Asia, Eastern Europe and Russia. I am a qualified teacher of English as a foreign language (TEFL) aand in the past I have used VB6 for this and for board and card games quite successfully.
×
×
  • Create New...